kinsigne
kinsigne

Reputation: 93

How to refresh a view in Django

I'm fairly new to Django and couldn't figure this one out. I have a HTML page with a form, and once the user clicks submit an external python script is called using celery. I have a view that can check if the celery job is done, but how do I continually poll the database to check if my job is done? Is there a way to "refresh" the view so that it continually polls the job status? I know you can do this in javascript, but I'm not sure how to integrate this with Django (is there some sort of module...)? Any help would be great, thanks!

Upvotes: 3

Views: 7365

Answers (2)

petacreepers23
petacreepers23

Reputation: 184

You can redirect yourself to your own html (https://realpython.com/django-redirects/) On your view.py, after the 'POST' case:

return redirect(request.META['HTTP_REFERER'])

Upvotes: 4

Matt
Matt

Reputation: 10312

You're on the right track. What you're looking for is Javascript and Ajax. This is a good answer.

Upvotes: 0

Related Questions