mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-12-22 22:21:47 +01:00
Refresh cache when clearing/generating data
This commit is contained in:
parent
4c4cd1ca03
commit
2799270bb8
2 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
from purchase.models import Basket, BasketItem, PaymentMethod, Product
|
||||
from purchase.models import Basket, BasketItem, Cache, PaymentMethod, Product
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -11,6 +11,7 @@ class Command(BaseCommand):
|
|||
self.delete(Basket)
|
||||
self.delete(Product)
|
||||
self.delete(PaymentMethod)
|
||||
Cache.get_solo().refresh()
|
||||
|
||||
def delete(self, cls):
|
||||
_, count = cls.objects.all().delete()
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.core.management import call_command
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.utils.timezone import now
|
||||
|
||||
from purchase.models import Basket, BasketItem, PaymentMethod, Product
|
||||
from purchase.models import Basket, BasketItem, Cache, PaymentMethod, Product
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -25,6 +25,7 @@ class Command(BaseCommand):
|
|||
with freezegun.freeze_time(now() + timedelta(hours=hour)):
|
||||
count += self.generate_baskets(payment_methods, products)
|
||||
|
||||
Cache.get_solo().refresh()
|
||||
self.stdout.write(self.style.SUCCESS(f"Successfully created {count} baskets."))
|
||||
|
||||
def delete(self, cls):
|
||||
|
|
Loading…
Reference in a new issue