title: How to return json dictionary in django ajax update
body: <p>i am asking this question multiple times since i have not received any applicable help. </p>
  
  <p>my problem is that i dont know how to return query result to template as an ajax response. </p>
  
  <p>i did this: </p>
  
  <pre><code>if request.path == "/sort/":
      sortid = request.POST.get('sortid')
      locs = Location.objects.order_by(sortid)
      if request.is_ajax():
          return HttpResponse(locs,mimetype="application/json")
  </code></pre>
  
  <p>then my ajax <code>done</code> function does this: </p>
  
  <pre><code>}).done(function(data){
  $('.sortierennach').html(data);
  });
  </code></pre>
  
  <p>what now happens is that it just replaces the content of <code>.sortierennach</code>, it is not rendering django dic so that i can do this: </p>
  
  <pre><code>{% for loc in locs %}
    {{loc.name}}
  {% endfor %}
  </code></pre>
  
  <p>can someone please help me... thanks a lot</p>