Fast, Extensible Progress Meter (tqdm) For Django.
It provides simple universal commands for Django management command to output
text using standard command functions and tqdm.
Only currently supported versions of Django and Python are supported.
from django_tqdm import BaseCommand
from time import sleep
class Command(BaseCommand):
def handle(self, *args, **options):
# Output directly
self.error("Error")
self.info("Info")
# Output through tqdm
t = self.tqdm(total=50)
for x in range(50):
sleep(0.03)
t.update(1)
if x == 10:
t.info("X = 10")
if x == 20:
t.error("X = 20")
Advanced:
info(text, ending="\n", fatal=False)
error(text, ending="\n", fatal=False)
write(text, ending="\n", fatal=False, error=False)
If you set fatal
to True
it will terminate the command after printing the message.
For documentation on tqdm see tqdm.
In django-tqdm:
self.info("info")
self.error("error")
In vanilla Django:
self.stdout.write("info")
self.stderr.write("error")
self.info("info")
self.error("error")
t = self.tqdm(total=50)
for x in range(50):
sleep(0.02)
t.update(1)
if x == 10:
t.info("info")
if x == 40:
t.error("error")
t = tqdm(total=50)
for x in range(50):
sleep(0.02)
t.update(1)
if x == 25:
t.write("info")
if x == 40:
t.write("error", file=sys.stderr)
Read developer documentation.