CSRF Error when submitting a form
Hey, I get this error when trying to submit a form from my django application
It's all working great when I host the website on my own and not on railway...
13 Replies
Yep, you need to pass the CSRF token in the request, or exempt the Railway domain.
You can get the CsrfViewMiddleware in the settings.py file
Hmm I have no idea how to do that :/, I'm normally sending the csrf token
Oh
What am I supposed to do with the csrfviewMiddleware?
the middleware is what makes the token
this is with my back of napkin memory of Django, but I am sure someone more knowlegable can help
Because I'm using {% CSRF_TOKEN %} for my forms
And it works when it's on my local machine
I think I fixed it
Working
@MadeInShineA I have the same issue, and I am just starting with Django and Railway. What did you do to fix this? It works perfectly fine on my localhost, but on Railway, I get the Forbidden error you have above.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thank you so much @Immaro!!! I’ll definitely give that a try!
Finally had a chance to work on it, and thank you so much! That solved my issue!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
how did u fix it? i'm having problems
was this in settings.py?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
like where?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i've tried but doesn't seem to be working