mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
13 lines
469 B
Python
13 lines
469 B
Python
from django.core.cache import cache
|
|
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from notifications.models import Notification
|
|
|
|
# Template for running actions after user have paid for a subscription
|
|
|
|
|
|
@receiver(post_save, sender=Notification)
|
|
def clear_cache_after_notification_update(sender, instance, **kwargs):
|
|
# Clear cache
|
|
cache.delete("notifications")
|
|
cache.delete(f"notifications_user:{instance.recipient.id}")
|