Home django CSRF check error. Request rejected

CSRF check error. Request rejected

Author

Date

Category

view.py

Def Create_Question (Request, Title, Text,):
Questions.title = title
Questions.Text = TEXT.
Questions.Save ()
RETURN QUESTION_DETAIL (Request, ID)

View

& lt; form action = "/ create_question /" Method = "POST" & gt;
  {% csrf_token%}
 & lt; div class = "textarea" & gt;
   & lt; label for = "email" & gt; topic & lt; / label & gt;
  & lt; Input Type = "Title" class = "Form-Control" id = "Email" & gt;
  & lt; label for = "textarea" & gt; text & lt; / label & gt;
   & lt; Textarea Class = "Form-Control" rows = "5" id = "text" & gt; & lt; / textarea & gt;
 & lt; / div & gt;
 & lt; Button Type = "Reply" Class = "BTN BTN-DEFAULT" & GT; Create & LT; / Button & GT;
& lt; / form & gt;

CSRF Tocken is what the problem does not understand.


Answer 1, Authority 100%

Not sure, but it is possible that they did not pass CSRF into the template. We must add:

context = {}
CONTEXT.UPDATE (CSRF (Request))

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions