django-maintenance-mode is a middleware that shows a 503 error page to users when maintenance mode is active in a Django project. The current version is 0.22.0. It maintains an active release cadence, frequently updating to support new Python and Django versions.
pip install django-maintenance-modeVerified import paths — ran on the pinned version, not inferred.
To enable maintenance mode, add `maintenance_mode` to your `INSTALLED_APPS` and `maintenance_mode.middleware.MaintenanceModeMiddleware` to your `MIDDLEWARE`. You can activate maintenance mode by setting `MAINTENANCE_MODE = True` in your settings or by using the `python manage.py maintenance_mode on` command. Configure exceptions for URLs, staff users, or specific IP addresses using settings like `MAINTENANCE_MODE_EXCEPT_URLS` and `MAINTENANCE_MODE_EXCEPT_STAFF`.
Upgrade your Python and Django versions to supported ones (e.g., Python 3.10+, Django 4.2+). Check the project's README for the latest compatibility matrix.
Update your `settings.py` to use `MAINTENANCE_MODE_GET_CONTEXT` instead of the old name.
Ensure the user running the Django process (e.g., Gunicorn, uWSGI) has write permissions to the directory where the state file (`maintenance_mode_state.txt`) is stored, or upgrade to 0.22.0+ which includes fixes for this specific issue.
If you require the `Retry-After` header for SEO or client-side retry logic, explicitly set `MAINTENANCE_MODE_RETRY_AFTER` in your `settings.py` to a positive integer (e.g., `3600` for 1 hour).