Extensions for using Rich with Django.
Requirements
Python 3.8 to 3.12 supported.
Django 3.2 to 5.0 supported.
Want to work smarter and faster?
Check out my book Boost Your Django DX which covers many ways to improve your development experience.
I wrote django-rich whilst working on the book!
Installation
Install with pip:
python -m pip install django-rich
None of django-rich’s features are activated by default.
Follow the documentation below to use them.
Reference
django_rich.management.RichCommand
A subclass of Django’s BaseCommand class that sets its self.console to a Rich Console.
The Console uses the command’s stdout argument, which defaults to sys.stdout.
Colourization is enabled or disabled according to Django’s --no-color and --force-color flags.
You can use self.console like so:
from django_rich.management import RichCommand
class Command(RichCommand):
def handle(self, args, *options):
self.console.print("[bold red]Alert![/bold red]")
You can customiz
|