[Fixed]-Django Polling of Import script – need user status update. Use model? Sessions?

1πŸ‘

βœ…

I don’t see an issue with a Job model that your background processing updates and then a view that your JavaScript polls. It may be useful in the future for analytics, too β€” you could track how long processing takes on average for files of a specific size, for example.

Roughly, something like this:

class Job(models.Model):
     user = models.ForeignKey('User', related_name='jobs')
     status = models.CharField(max_length=255)
     created_on = models.DateTimeField(auto_now_add=True)
     updated_at = models.DateTimeField(auto_now=True)

Then, on file upload, create a new Job, and pass it to your front-end so that it can poll the job status view you create.

πŸ‘€J. McBride

Leave a comment