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:
- 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 forPOST
requests. - 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
.
Source:stackexchange.com