[Fixed]-Problems using Ajax with Django

1👍

When doing AJAX using Django I do it this way:

  1. Define a route(view) that will serve your default template containing your ajax call script.
  2. 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')
    
  3. And you will call the second route in your ajax call

Hope it helps you

Leave a comment