Code Monkey home page Code Monkey logo

Comments (8)

fabiocaccamo avatar fabiocaccamo commented on June 7, 2024

@ryselis nice idea. I will add it as soon as possible, in the meanwhile feel free to send a PR.

from django-maintenance-mode.

fabiocaccamo avatar fabiocaccamo commented on June 7, 2024

@ryselis how do you expect to pass context data to the 503 view?

from django-maintenance-mode.

ryselis avatar ryselis commented on June 7, 2024

I have 2 ideas.

  1. Abstract out template rendering into its own method. Instead of calling render_to_response directly in middleware's process_request, add a new method to MaintanenceModeMiddleware that does the rendering. If I want to do it differently, I override your middleware class and rewrite just this one method that renders the template.
  2. Make some kind of hook that would let me specify just the context. For example, add a setting like MAINTENANCE_MODE_TEMPLATE_RENDER_CONTEXT so that I could assign a function to it, so it would look like this:
    MAINTENANCE_MODE_TEMPLATE_RENDER_CONTEXT = get_maintenance_context
    and I would have
    def get_maintenance_context(request):
    # return the context
    in my code.

from django-maintenance-mode.

ryselis avatar ryselis commented on June 7, 2024

This is my current workaround

from django-maintenance-mode.

fabiocaccamo avatar fabiocaccamo commented on June 7, 2024

@ryselis the solution 1 is the one that I imagined, anyway the solution 2 could be a good alternative, I will add support for both solutions. Thanks

from django-maintenance-mode.

fabiocaccamo avatar fabiocaccamo commented on June 7, 2024

@ryselis in any case it's always possible to specify a custom template and load some template tags from it.

from django-maintenance-mode.

ryselis avatar ryselis commented on June 7, 2024

@fabiocaccamo yes, this is a possibility, but it is not an intuitive solution, at least for me

from django-maintenance-mode.

fabiocaccamo avatar fabiocaccamo commented on June 7, 2024

@ryselis just released 0.3.2 version.

Now it's possible to specify a custom function using the setting MAINTENANCE_MODE_TEMPLATE_CONTEXT or extend the middleware and override the get_request_context method.

from django-maintenance-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.