1👍
✅
When doing AJAX using Django I do it this way:
- Define a route(view) that will serve your default template containing your ajax call script.
-
Add another route(view) for the ajax call:
def auto_complete(request): # do some actions and put the results in var return HttpResponse(simplejson.dumps(var),content_type='application/json')
-
And you will call the second route in your ajax call
Hope it helps you
Source:stackexchange.com