django-rich is a Python library that provides extensions for integrating the Rich library with Django projects. It enhances the Django development experience by enabling Rich's pretty-printing in the Django shell, providing Rich-powered tracebacks for the test runner, and offering a `RichCommand` base class for creating visually appealing management commands. The library is currently at version 2.2.0 and receives regular updates to support the latest Django and Python versions.
pip install django-richVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a custom Django management command that leverages `django-rich`'s `RichCommand` base class. This allows you to use `Rich`'s console, status indicators, and styled output directly within your command, inheriting Django's colorization flags. Save this as `your_app/management/commands/mycommand.py` and run `python manage.py mycommand`.
Update your `make_rich_console` override to be a standard instance method or wrap it with `staticmethod()` if it doesn't need `self`.
Ensure your Django project is running on a supported version (Django 4.2 to 6.0 for django-rich 2.2.0).
Upgrade your Python environment to 3.10 or later (Python 3.10 to 3.14 are supported by django-rich 2.2.0).
If using IPython, refer to the official Rich documentation for IPython integration.
First, install the package: `pip install django-rich`. Then, add `'django_rich'` to your `INSTALLED_APPS` list in your Django `settings.py` file.
If you defined `make_rich_console` using `functools.partial`, remove `partial` and implement it as a standard method. Example: `def make_rich_console(self, **kwargs): return super().make_rich_console(**kwargs, markup=False)`
Add `'django_rich'` to your `INSTALLED_APPS` list in `settings.py`. If you're using `IPython`, `django-rich`'s shell integration will not work; consult Rich's documentation for IPython-specific setup.