Django Extensions
Django Extensions is a comprehensive collection of custom extensions for the Django Framework, designed to enhance development workflow. It includes a wide array of management commands (e.g., `shell_plus`, `runserver_plus`, `graph_models`), additional database fields, and admin interface improvements. Currently at version 4.1, it maintains an active release cadence, frequently updating to support the latest Django and Python versions.
Warnings
- breaking Starting with version 4.0, Django Extensions transitioned from `setup.cfg` / `setup.py` to `pyproject.toml` for project configuration. This change primarily affects packaging and build systems for contributors or those installing from source.
- breaking The `mail_debug` command was updated in version 4.0 to use `aiosmtpd` for its SMTP server implementation. The old `smtpd` module from the Python standard library is deprecated in Python 3.6 and removed in Python 3.12.
- gotcha The `graph_models` command, while requiring Python packages like `pygraphviz` or `pydot`, also relies on a *system-wide* installation of Graphviz to render images. Without it, the command will fail even if Python dependencies are met.
- gotcha The `runserver_plus` command requires `Werkzeug`. While typically installing `Werkzeug` resolves this, some users have reported issues with specific `Werkzeug` versions leading to `CommandError: Werkzeug is required...` or `KeyError: 'werkzeug.server.shutdown'`.
- deprecated The `passwd` management command was deprecated in version 3.0.0. Its functionality is now superseded by Django's built-in `changepassword` command.
- breaking Django Extensions 4.1 officially requires Django 4.2 or later and Python 3.9 or later. Version 4.0 introduced support for Django 5.x and Python 3.12/3.13.
Install
-
pip install django-extensions
Imports
- AutoSlugField
from django_extensions.db.models.fields import AutoSlugField
- CreationDateTimeField
from django_extensions.db.models.fields import CreationDateTimeField
- ModificationDateTimeField
from django_extensions.db.models.fields import ModificationDateTimeField
- RandomCharField
from django_extensions.db.models.fields import RandomCharField
- ShortUUIDField
from django_extensions.db.models.fields import ShortUUIDField
- JSONField
from django_extensions.db.models.fields import JSONField
Quickstart
# settings.py
INSTALLED_APPS = [
# ... other Django apps
'django_extensions',
# ...
]
# Then, run management commands from your project root:
# python manage.py shell_plus
# python manage.py runserver_plus
# python manage.py graph_models -a -o my_project_models.png