mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
14 lines
469 B
Python
14 lines
469 B
Python
|
from django.dispatch import receiver
|
||
|
from django.db.models.signals import post_save
|
||
|
from notifications.models import Notification
|
||
|
from django.core.cache import cache
|
||
|
|
||
|
# 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}')
|