[Answer]-Django POST not calling view


You can’t return a redirect from within get_context_data – it’s for context data only, hence the name.

You should really be using a proper form view for this, which includes methods for redirecting after form validation.


Did you include a csrf_token in your template (as per the example here: http://www.djangobook.com/en/2.0/chapter07.html)?

<form action="" method="post">
        {{ form.as_table }}
    {% csrf_token %}
    <input type="submit" value="Submit">

I could be wrong, but I thought Django wouldn’t accept a POST request without a csrf token?


Leave a comment