Extensions for using Rich with Django.
Project description
Extensions for using Rich with Django.
Requirements
Python 3.6 to 3.10 supported.
Django 2.2 to 4.0 supported.
Are your tests slow? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can write faster, more accurate tests.
Installation
Install with pip:
python -m pip install django-rich
Reference
django_rich.management.RichCommand
A subclass of Django’s BaseCommand class that sets its self.console to a Rich Console. It tries to correctly enable/disable colourization based on Django’s --no-color and --force-color flags. Use this for Rich output in your management commands.
For example:
from django_rich.management import RichCommand
class Command(RichCommand):
def handle(self, *args, **options):
self.console.print("[bold red]Alert![/bold red]")
You can customize the construction of the Rich console by overriding the make_rich_console class attribute. This should be a callable that will construct a Console, such as a functools.partial. For example, to disable Rich’s default console markup and highlighting:
from functools import partial
from django_rich.management import RichCommand
from rich.console import Console
class Command(RichCommand):
make_rich_console = partial(Console, markup=False, highlight=False)
def handle(self, *args, **options):
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_rich-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3e3e0f263300fda9090663a8c963cdee51a70fd62361e040548857fcbdbb6c7 |
|
MD5 | 61136c7dcb0f0765ef7ed6e79d28862b |
|
BLAKE2b-256 | a92d5e2a41009ba8abb506cbe664727f0fbe2c22184cea96080601144465b862 |