[Answer]-Rendering requests with Django

1👍

The problem is how you submit the form. Since you are using ajax – the resulting HTML is being sent back to your ajax call, where its not rendered and simply discarded.

To fix this:

  1. Use a standard form (don’t forget {% csrf_token %}. You can then render the template as you are doing now – or – redirect to the view as is best practice for POST requests.
  2. If you want to use ajax, capture the result with a callback, and render the response. If you want to do this, simply return the JSON without a template. Update your form HTML with the javascript in your results.html.

Leave a comment