-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSRF validation failure when using "HTML Form" to POST #4471
Comments
"POST using "HTML Form" to serializer which expects valid authenticated user." |
@xordoquy Yes, I am talking about browsable API. The problem is that request.user is not determined correctly when "X-CSRFToken" is not sent. I am using session authentication in this case. To put it simply, "Raw data" form works for me while "HTML Form" doesn't. And this is definitely because of the CSRF header. |
I'm puzzled. The HTML Form do work for me. How do I reproduce the issue ? |
@xordoquy set
|
I just did that and it works without issues with: I'm going to close this issue for now. |
Checklist
master
branch of Django REST framework.Steps to reproduce
Expected behavior
Actual behavior
The culprit
rest_framework/static/rest_framework/js/ajax-form.js: lines 26-30:
Since "HTML Form" doesn't override
contentType
, request is posted via Form (not AJAX) and "X-CSRFToken" is not added.I think the aforementioned piece of code could be simply deleted unless anyone knows a good reason why it is necessary :)
The text was updated successfully, but these errors were encountered: