0

i'm working my project with django restframework, all is right except when i try to update a table, always appears the CSRF.

How i can set CSRF cookie? Thanks

Screenshot

  • 1
    Related http://stackoverflow.com/questions/37340163/what-is-the-proper-way-to-send-and-receive-json-requests-in-django/37340742#37340742 – dani herrera May 25 '16 at 19:42
  • thanks danihp, this is useful, but my problem right now is with the api and admin, i can add data, but when i try to update o delete send me the screenshot error, is the same and admin. – Nestor Moran May 25 '16 at 20:46
  • You do not set it, django issues a request with `Set-Cookie` and the browser shall respond back with `Cookie`. I bet your browser is misconfigured (i.e. do not accept cookies or only accept them from known parties). Check the HTTP headers for `Set-Cookie` (in the GET that gives the admin form) and for `Cookie` (in the POST you send when you click `Save`) – grochmal May 25 '16 at 21:16
  • Nestor can you also add your urls.py in the question? I once encountered same problem and turned out I made a mistake there. – mascot6699 May 26 '16 at 05:17

1 Answers1

0

I experienced this earlier today while switching development projects and added to an existing thread here: Django CSRF Cookie Not Set

After checking the order of installed apps and middleware against the startproject template, clearing my browser cache resolved the issue.

Community
  • 1
  • 1
datasmith
  • 704
  • 8
  • 14