I would like to update my model object once a celery task has completed. I am currently at a loss about how to go about doing this though.
Here is a layout of the files
from photos.tasks import photo_download
class Photo(models.Model):
....fields....
@receiver(post_save)
def download_photo_callback(sender, **kwargs):
photo = kwargs["instance"]
result = photo_download.delay(photo.uid)
from photo.models import Photo
@task()
def photo_download(photo_uid, callback=None):
...do stuff...
photo.status = 'D'
photo.save()
You're doing a circular import. Your tasks.py
file is importing your models.py
file and vice-versa. You should move your signals to a separate signals.py
file to avoid it.