Skip to content
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 token is not rendered in TurboStream Responses #11

Closed
JulianFeinauer opened this issue Apr 16, 2022 · 4 comments
Closed

csrf token is not rendered in TurboStream Responses #11

JulianFeinauer opened this issue Apr 16, 2022 · 4 comments
Assignees

Comments

@JulianFeinauer
Copy link

If you render a Form containing {% csrf_token %} it is not rendered.

This is related to this issue: https://stackoverflow.com/questions/34629261/django-render-to-string-ignores-csrf-token

@JulianFeinauer JulianFeinauer self-assigned this Apr 16, 2022
@chrisgrande
Copy link
Contributor

I'm not seeing this, are you adding the request to .response() when you return the TurboStream, like so .response(request=request).

The docs just have .response(request), I updated via a pull request but the rendered docs don't seem to have updated.

@JulianFeinauer
Copy link
Author

Thanks @chrisgrande, indeed i didn't update the docs and i tried to pass the request via kwargs but it didn't work for me... Strange

@danjac
Copy link
Collaborator

danjac commented Apr 17, 2022

.response(request=request) indeed should work (I've added a couple tests to confirm). Perhaps @JulianFeinauer if you could provide more context for what you are doing?

@JulianFeinauer
Copy link
Author

@danjac and @chrisgrande you both are right. I tried it again and it works. No idea what I did wrong initially.
So we can either keep it as is to have the request more explicit as variable or close this PR. Its up to you : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants