How simple? The intended goal is to have the total number of 'dirts' update without user intervention. Laaaammmeee. If you are a visual type of person, take a look on the Colddirt huh page. That number automatically increases without user intervention. And this is how.
The process (some pseudocode) will go like this:
check /dirt_count/ for an update
if update:
make number bigger
else:
check less frequently
Pretty simple, eh?
urls.py
(r'^dirt_count/$', views.dirt_count),
As you can see, it just sends the request to the view.
views.py
def dirt_count(request): from django.http import HttpResponse countd = str(Dirt.objects.all().count()) return HttpResponse(countd, mimetype='text/plain')
Pretty simple -- count the dirts. That makes sense.
dirty.js
new Ajax.PeriodicalUpdater('dirtcount', '/dirt_count/', { method: 'get', frequency: 3, decay: 2, });
Yea, Prototype makes that real easy. Just make sure to have a element in your template somewhere with an id of 'dirtcount'.
templates/huh.html
0