Created
August 3, 2012 23:39
-
-
Save mgrouchy/3252725 to your computer and use it in GitHub Desktop.
csrf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
def view(request): | |
form = FormClass() | |
return render(request, 'formpage.html', RequestContext(request, {'form': form})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<form action="{% url some.view.here %}" method="post"> | |
{% csrf_token %} | |
{{ form.as_p }} | |
</form> | |
</body> | |
</html> | |
{% comment %} | |
- You must render this view with a form(for variable form) | |
- View must be rendered using RequestContext | |
- You must have django.middleware.csrf.CsrfViewMiddleware middleware in your Middleware settings | |
{% endcomment %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment