2👍
Since you want to do regular asynch calls to your server while a page is already loaded, I would use AJAX to solve this problem.
I’d usually do something like this
def your_django_view(request):
# magic
server_data = '98% left!'
response_data['data'] = server_data
return HttpResponse(json.dumps(response_data), content_type="application/json")
Then in your view, use some jquery (or javascript..whatever) to deal with all of the data
$.ajax({type: 'POST',
url: '/function_url/',
data: {
},
success: function(response_data) {
var server_mem = response_data['data']
$('#disk_space').val(server_mem);
})
👤rob
0👍
Use this return statement at the end of your submit
view:
return render_to_response('Checklist/stop.html',
{'disk_space':disk_space},
context_instance=RequestContext(request))
The second argument of render_to_response
is a dictionary of {'key':value, 'key2':value2}
you can use in the template.
Source:stackexchange.com