Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_dynamic_maintenance_mode-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_dynamic_maintenance_mode-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django_dynamic_maintenance_mode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9db2c2fd306a42b54e55a5779b058265f6a643ca8d063d03f673ae3a701529ea
MD5 a6ace0748e2fef0ed0db10ead2c2e3bc
BLAKE2b-256 c2842292d091ec90d69d49bbd16dc9ca947ddd241b5d100a9c9ce2402b3bf5c3

See more details on using hashes here.

File details

Details for the file django_dynamic_maintenance_mode-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_dynamic_maintenance_mode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a59973cee47f3236563c8c3827419a091260bbd7f5c333820e85a670ac84c0
MD5 b3c6b1f7602032fe84487537f7b622df
BLAKE2b-256 c1a8451a3b48e9a1f16e4446daeed31e17dd118de218508d8a8e959dce8f802e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page