title: Django - JSON returned from Ajax success to be used in a template
body: <p>Say I have a Django queryset being displayed in a template with the following view...</p>
  
  <pre><code>def objects_view(request):
      user = request.user
      query = request.GET.get('q')
      objects = Product.objects.filter(title = q)
      context = {'user':user,'query':query,'objects':objects}
      return render(request, 'template.html', context)
  </code></pre>
  
  <p>Then an Ajax function in the template.html will be called when a user changes the values of minimum or maximum price like so...</p>
  
  <pre><code>$('#apply-price-changes').click(function(){
      var Url = window.location.path; # Calling the same URL so we are POSTing to the same view
      var priceMin = $('#price-min-hidden').val();
      var priceMax = $('#price-max-hidden').val();
      $.ajax({
        async:true,
        method:'POST',
        url:Url,
        data:{
          'minPrice':priceMin,
          'maxPrice':priceMax,
        },
        dataType:'json',
        success:function(data){
          console.log(data) # &lt;- This logs all of the filtered objects (in JSON format) in the console
          # Not sure what I'd write to go here, this bit is the problem
        },
        error:function(error){
          console.log(error)
        }
      })
  });
  </code></pre>
  
  <p>So now in my view I include a POST request to get the minimum and maximum price values...</p>
  
  <pre><code>def objects_view(request):
      user = request.user
      query = request.GET.get('q')
      objects = Product.objects.filter(title = q)
      if request.method == 'POST':
          minPrice = request.POST.get('minPrice')
          maxPrice = request.POST.get('maxPrice')
          objects = Product.objects.filter(title = q, price__gte = minPrice, price__lte = maxPrice)
          data = serializers.serialize('json',objects)
          return HttpResponse(json.dumps(data), content_type='application/json')
      context = {'user':user,'query':query,'objects':objects}
      return render(request, 'template.html', context)
  </code></pre>
  
  <p>Now I'd like to have the result of that data be displayed in the template so that users can see products that only match the filtered queryset, and also be able to do some 'if' statements with that data.</p>
  
  <p>HTML Template example:</p>
  
  <pre><code>{% if objects.count &gt; 0 %}
  {% for object in objects %}
  &lt;h3&gt;{{ object.title }}&lt;/h3&gt;
  &lt;h4&gt;{{ object.description }}&lt;/h4&gt;
  &lt;h4&gt;{{ object.price }}&lt;/h4&gt;
  {% endfor %}
  {% else %}
  No objects to display!
  {% endif %}
  </code></pre>
  
  <p>Please let me know if there's any more code I should show. Note that I do not want to print every bit of the information return from JSON, such as the primary key of each object.</p>
  
  <p>Thanks!</p>