I'm monitoring the temperature for different locations. I have the data stored in a model and have set my views.py, but I would like to refresh the table every 5 minutes. I'm new to ajax and dajaxice, how can I write the function so it displays in html? this is my views.py:
def temperature(request):
temperature_dict = {}
for filter_device in TemperatureDevices.objects.all():
get_objects = TemperatureData.objects.filter(Device=filter_device)
current_object = get_objects.latest('Date')
current_data = current_object.Data
temperature_dict[filter_device] = current_data
return render_to_response('temp.html', {'temperature': temperature_dict})
As for what I think I'm understanding so far, this could be my ajax.py, I should just modify it to return a simplejson dump. Please correct me if Im wrong. This is my temp.html:
<table id="tval"><tr>
{% for label, value in temperature.items %}
<td>{{ label }}</td>
<td>{{ value }}</td>
{% endfor %}
</tr></table>
Here is where I get stuck. How can I write this so that my callback refreshes the table?