Merge conditionals

This commit is contained in:
Jeremy Stretch 2023-08-29 15:07:08 -04:00
parent 417b57171a
commit 7f643f9c58

View File

@ -39,9 +39,8 @@ def post_save_receiver(sender, instance, created, **kwargs):
# Update the counters on the old and/or new parents as needed
if old_pk is not None:
update_counter(parent_model, old_pk, counter_name, -1)
if new_pk is not None:
if old_pk or created:
update_counter(parent_model, new_pk, counter_name, 1)
if new_pk is not None and (old_pk or created):
update_counter(parent_model, new_pk, counter_name, 1)
def post_delete_receiver(sender, instance, **kwargs):