Add post save to delete album cover cache
This commit is contained in:
parent
ec6acaf8ea
commit
25971efbfb
1 changed files with 7 additions and 0 deletions
|
@ -5,6 +5,8 @@ from django.core.cache import cache
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.db.models import Sum
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.templatetags.static import static
|
||||
from django.urls import reverse
|
||||
from django.utils.text import slugify
|
||||
|
@ -59,3 +61,8 @@ class Album(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.name)
|
||||
|
||||
|
||||
@receiver(post_save, sender=Album)
|
||||
def delete_album_cover_cache(sender, instance, **kwargs):
|
||||
cache.delete(f'cover_image_data_{instance.pk}')
|
Loading…
Add table
Reference in a new issue