6347 only update count if created

This commit is contained in:
Arthur 2023-05-16 15:45:55 -07:00
parent eb0c901a9f
commit c7a4fd14ee

View File

@ -37,7 +37,8 @@ class Counter(object):
name = f"{self.parent_model._meta.model_name}.{self.child_model._meta.model_name}.{self.foreign_key_field.name}"
counted_name = f"{name}-{self.counter_name}"
def post_save_receiver_counter(sender, instance, **kwargs):
def post_save_receiver_counter(sender, instance, created, **kwargs):
if created:
self.increment(instance, 1)
post_save.connect(