Registry / web-framework / django-rich

django-rich

JSON →
library2.2.0pypypi✓ verified 89d ago

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-rich
INSTALL
IMPORT
SIG · DJANGO-RICH
D
django-rich
web-frameworkpythonv2.2.0
Install
4.4s avg
Import
433ms
Disk
78MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.915 runs
installs and imports cleanly · install 0.0s · import 0.447s · 78.6MB
glibc
py 3.10–3.915 runs
installs and imports cleanly · install 4.4s · import 0.419s · 79MB
78MB installed
● package 78MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RichCommand
✓ from django_rich.management import RichCommand
✗ from rich.console import Console # Directly instantiating Console without RichCommand context
Use RichCommand as a base for Django management commands to get integrated console features, including colorization based on Django's --no-color/--force-color flags.
django_rich (in INSTALLED_APPS)
✓ INSTALLED_APPS = [ # ... 'django_rich', # ... ]
Adding 'django_rich' to INSTALLED_APPS activates the enhanced Django shell and Rich tracebacks in the test runner.

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`.

import time from django_rich.management import RichCommand class Command(RichCommand): help = "A sample management command using django-rich." def handle(self, *args, **options): self.console.print("[bold blue]Starting a complex operation:[/bold blue]") with self.console.status("Processing items...") as status: for i in range(1, 11): status.update(f"[yellow]Processing item {i} of 10...[/yellow]") time.sleep(1) # Simulate work self.console.log(f"[green]Item {i} processed.[/green]") self.console.print("[bold green]Operation complete![/bold green]")
Debug
Known issues
breakingIn version 2.0.0, the `make_rich_console()` method on `RichCommand` was changed from being a `partial()` to a regular method. If you overrode this method in previous versions using `functools.partial`, your code will break.
fix
Update your `make_rich_console` override to be a standard instance method or wrap it with `staticmethod()` if it doesn't need `self`.
affects: >=2.0.0
breakingVersion 1.13.0 dropped official support for older Django versions (3.2 to 4.1).
fix
Ensure your Django project is running on a supported version (Django 4.2 to 6.0 for django-rich 2.2.0).
affects: >=1.13.0
breakingVersion 2.1.0 dropped support for Python 3.9.
fix
Upgrade your Python environment to 3.10 or later (Python 3.10 to 3.14 are supported by django-rich 2.2.0).
affects: >=2.1.0
gotchaThe enhanced Django shell features (pretty-printing and automatic imports) provided by `django-rich` only apply to the standard Python interpreter and `bpython`, not `IPython`.
fix
If using IPython, refer to the official Rich documentation for IPython integration.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'django_rich'
The `django-rich` package is either not installed in your environment or, if installed, has not been added to your Django project's `INSTALLED_APPS` setting.
fix
First, install the package: `pip install django-rich`. Then, add `'django_rich'` to your `INSTALLED_APPS` list in your Django `settings.py` file.
TypeError: Command.make_rich_console() takes 1 positional argument but 2 were given
This error typically occurs after upgrading `django-rich` to version 2.0.0 or later. The `make_rich_console` method, when overridden in a custom `RichCommand`, changed its signature from a `functools.partial` to a regular instance method.
fix
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)`
Django shell output is not pretty-printed by Rich, or Rich functions like `inspect()` are not automatically available.
The `django_rich` app is not included in your `INSTALLED_APPS` setting, or you are using `IPython` which is not directly supported by `django-rich`'s shell integration.
fix
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.
Upgrade
Version history
2.2.0latest on PyPI · released Sep 18, 2025
Audit
Dependencies
richrequiredCore dependency for rich text formatting and console output.
DjangorequiredThe framework this library extends.
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
2
Resources
django-rich — pip install django-rich · libregistry