I'm planning a project that will make use of Celery tasks that will perform CRUD operations on my models. In addition, I have Signals in place that will listen for those CRUD operations and I want to specifically log that it was a Celery task (or a Celery task user) performing the operation.
So would I accomplish assigning a User to my Celery workers so that whenever they interact with my models I can track that?
@receiver(pre_save, sender=Location)
def location_pre_save(sender, instance, update_fields=None, **kwargs):
try:
old_location = Location.objects.get(id=instance.id)
# Log Celery user has updated this Location
except Location.DoesNotExist:
# Log Celery user has created this Location