I'm using redis for caching data on my project and delete the cache through the signal. Whenever there is a change on my database the signal clear the cache using the key provided as follow:
@receiver(post_save, sender=Book)
def cache_clean_books(sender, instance, created, **kwargs):
if created:
cache.delete("all_books")
else:
cache.delete(f'book_id_{instance.id}')
Everything is working fine from here but when I use python manage.py flush to clear data from the database my signal is not triggered. Is there any way I can use to hit the signal whenever I flush data in django please?