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?
- [Answer]-Resolve user type in authentication in Django
- [Answer]-How to change some fields' values in models.Model in django?
- [Answer]-How to Fake django.contrib.auth User value for specific user?
- [Answer]-Django: generic delete view
Source:stackexchange.com