views:

59

answers:

2

Hi, Im writing an app in Django to monitor certain services in a group of servers. I would like to have the views updated periodically. So far I've looked at writing custom admin commands (link here) and have {% ifchanged %} tags in my template. I just wanted to know if this is the best approach or if there is a better way to do it, like auto refresh certain portions of the webpage or something else. Thanks.

A: 

The ifchanged template tag is really for when you're processing a series of objects within a template, and want to do something if a field changes from one object to the next. That probably won't meet your needs.

If you just want the data backing your models to be updated periodically, then writing a custom command and running it periodically with a cron job makes the most sense.

If you want the user interface to refresh itself periodically, there are lots of ways to do that: meta-refresh tags, javascript/jquery tricks, or even using AJAX to update the displayed data.

Craig Trader
+1  A: 

If you're wanting to run something periodically, I would suggest looking at celery tasks (see here for a brief tutorial).

From there, like Craig Trader mentioned, you could use AJAX to check the status of the tasks (django-celery has some built in views and urls you can use).

DavidB
Thanks. I looked at celery but I found chronograph a bit easier to use.
Ping Pengũin