Files
backend/apps/geology/signals/gallery.py
A'zamov Samandar 0229a0595c
Some checks failed
Deploy Django Application to Server / deploy (push) Failing after 19s
Telegram Notifications / Telegram Gate (push) Failing after 5s
gealogiuya
2026-02-27 14:56:23 +05:00

13 lines
434 B
Python

from django.db.models.signals import m2m_changed
from django.dispatch import receiver
from apps.geology.models import GalleryCategory
@receiver(m2m_changed, sender=GalleryCategory.gallery.through)
def gallery_category_m2m_changed(sender, instance, action, **kwargs):
if action in ["post_add", "post_remove", "post_clear"]:
instance.count = instance.gallery.count()
print(instance.count)
instance.save()