Django middleware to enable maintenance mode dynamically using a database flag.
Project description
django-dynamic-maintenance-mode
Django middleware to enable maintenance mode dynamically using a database flag. Works for both web views and Django REST Framework APIs.
Features
- Toggle maintenance mode from the admin panel
- Superusers can bypass maintenance restrictions
- Admin routes are always accessible
Installation
pip install django-dynamic-maintenance-mode
Configuration
Add to INSTALLED_APPS in settings.py:
'dynamic_maintenance',
Add to MIDDLEWARE near the top:
'dynamic_maintenance.middleware.DynamicMaintenanceMiddleware',
Run migrations:
python manage.py migrate
Use the admin panel to toggle maintenance mode.## Usage
Enable or Disable Maintenance Mode
You can toggle the maintenance mode from the Django Admin panel or using Django shell:
python manage.py shell
Then in shell:
from dynamic_maintenance.models import MaintenanceMode
mode, created = MaintenanceMode.objects.get_or_create(id=1)
mode.is_active = True # or False to disable
mode.message = "We are performing scheduled maintenance. Please check back soon."
mode.save()
Alternatively, you can create a custom Django management command for enabling/disabling maintenance mode.
Enable or Disable Maintenance Mode CMD
Commands to enable/disable maintenance mode dynamically
```bash
python manage.py maintenance_mode on
python manage.py maintenance_mode off
```
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_dynamic_maintenance_mode-0.1.0.tar.gz.
File metadata
- Download URL: django_dynamic_maintenance_mode-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9db2c2fd306a42b54e55a5779b058265f6a643ca8d063d03f673ae3a701529ea
|
|
| MD5 |
a6ace0748e2fef0ed0db10ead2c2e3bc
|
|
| BLAKE2b-256 |
c2842292d091ec90d69d49bbd16dc9ca947ddd241b5d100a9c9ce2402b3bf5c3
|
File details
Details for the file django_dynamic_maintenance_mode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_dynamic_maintenance_mode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6a59973cee47f3236563c8c3827419a091260bbd7f5c333820e85a670ac84c0
|
|
| MD5 |
b3c6b1f7602032fe84487537f7b622df
|
|
| BLAKE2b-256 |
c1a8451a3b48e9a1f16e4446daeed31e17dd118de218508d8a8e959dce8f802e
|