I have a question regarding the usage of dispatch_uid
for signals.
Currently, I am preventing multiple usage of the signal by simply adding if not instance.order_reference
. I wonder now if dispatch_uid
has the same functionality and I can delete the "if not
" clause.
signals.py
def reserveditem_create_order_reference(sender, instance, **kwargs):
if not instance.order_reference:
instance.order_reference = unique_order_reference_generator()
app.py
class OrdersConfig(AppConfig):
name = 'orders'
def ready(self):
#Pre save signal for ReservedItem model
reserved_model = self.get_model('ReservedItem')
pre_save.connect(
reserveditem_create_order_reference,
sender=reserved_model,
dispatch_uid="my_unique_identifier"
)