Comments (8)
@ryselis nice idea. I will add it as soon as possible, in the meanwhile feel free to send a PR.
from django-maintenance-mode.
@ryselis how do you expect to pass context data to the 503 view?
from django-maintenance-mode.
I have 2 ideas.
- Abstract out template rendering into its own method. Instead of calling
render_to_response
directly in middleware'sprocess_request
, add a new method toMaintanenceModeMiddleware
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. - 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.
from django-maintenance-mode.
@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.
@ryselis in any case it's always possible to specify a custom template and load some template tags from it.
from django-maintenance-mode.
@fabiocaccamo yes, this is a possibility, but it is not an intuitive solution, at least for me
from django-maintenance-mode.
@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)
- Add new setting to expire the user session HOT 4
- ModuleNotFoundError: 'utils.middleware.maintenance' While running testcases HOT 1
- Add Django Cache Backend HOT 2
- Support JSON content type HOT 2
- `set_maintenance_mode` should use atomic write. HOT 8
- `manage.py maintenance_mode on/off` changes permissions of state file HOT 12
- Inherit state file permissions from the directory where it is created.
- File Write Errors on Windows Systems HOT 6
- Banner for all templates to warn users when maintenance will be HOT 1
- 404 Not Found Error When SCRIPT_NAME Defined HOT 10
- FileNotFoundError with default settings HOT 1
- IGNORE_IP not working HOT 6
- CommandError: Unable to write state file at: maintenance_mode_state.txt HOT 1
- Working fine on dev box but not functioning on test box with virtual directory HOT 11
- force_maintenance_mode_off doesn't work for AJAX requests HOT 1
- Problem with ipware version HOT 1
- Unable to use with s3 storage HOT 4
- Add maintenance mode toggler in the admin site HOT 1
- MAINTENANCE_MODE_STATE_FILE_PATH setting bug HOT 2
- Drop `Python < 3.8` and `Django < 2.2` support.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-maintenance-mode.