[Answer]-Django POST not calling view

1👍

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.

0👍

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">
    <table>
        {{ form.as_table }}
    </table>
    {% csrf_token %}
    <input type="submit" value="Submit">
</form>

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

👤erewok

Leave a comment