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
angelo
angelo3y ago
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
MadeInShineA
MadeInShineAOP3y ago
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?
angelo
angelo3y ago
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
MadeInShineA
MadeInShineAOP3y ago
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
MantisInABox
MantisInABox3y ago
@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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
MantisInABox
MantisInABox3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Gaura
Gaura2y ago
how did u fix it? i'm having problems was this in settings.py?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Gaura
Gaura2y ago
like where?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Gaura
Gaura2y ago
i've tried but doesn't seem to be working
Want results from more Discord servers?
Add your server