mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-05-02 18:55:09 +02:00
18 lines
537 B
Python
18 lines
537 B
Python
from django.core.management.base import BaseCommand
|
|
|
|
from purchase.models import Basket, BasketItem, PaymentMethod, Product
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Clear all data" # noqa: A003
|
|
|
|
def handle(self, *args, **options): # noqa: ARG002
|
|
self.delete(BasketItem)
|
|
self.delete(Basket)
|
|
self.delete(Product)
|
|
self.delete(PaymentMethod)
|
|
|
|
def delete(self, cls):
|
|
_, count = cls.objects.all().delete()
|
|
self.stdout.write(self.style.WARNING(f"Successfully deleted {count} {cls}."))
|