ridethepony/django-fiber — Issue #55: Missing csrf_token on second POST when adding a page
Author: reinout
Created: 2012-01-30 16:36:54+00:00
State: open

I'm trying to bolt django-fiber onto our existing system. Of course, that's got a tad of javascript lying around, which perhaps causes the problem. Anyway, I've got the csrf middleware enabled; django 1.3; even Django's suggested javascript snippet to work around csrf issues in ajax posts.

But when I want to add a new page, I get a 403 with a missing csrf token:

[30/Jan/2012 17:20:41] "GET /static_media/fiber/js/ckeditor-3.6.2/skins/kama/icons.png HTTP/1.1" 304 0
[30/Jan/2012 17:20:41] "GET /static_media/fiber/js/ckeditor-3.6.2/plugins/styles/styles/default.js?t=B8DJ5M3 HTTP/1.1" 304 0
[30/Jan/2012 17:20:44] "POST /admin/fiber/fiber_admin/fiber/contentitem/add/ HTTP/1.1" 302 0
[30/Jan/2012 17:20:44] "GET /admin/fiber/fiber_admin/fiber/contentitem/3/ HTTP/1.1" 200 1885
[30/Jan/2012 17:20:45] "GET /admin/fiber/fiber_admin/jsi18n/ HTTP/1.1" 200 1689
[30/Jan/2012 17:20:45] "GET /jsi18n/ HTTP/1.1" 200 745
[30/Jan/2012 17:20:47] "GET /static_media/fiber/js/ckeditor-3.6.2/config.js?t=B8DJ5M3 HTTP/1.1" 304 0
WARNING Forbidden (CSRF token missing or incorrect.): /api/v1/page_content_items/
[30/Jan/2012 17:20:47] "POST /api/v1/page_content_items/ HTTP/1.1" 403 2332

The strange thing is that it is the second POST that fails, the first one is OK. I see a csrf token in the first request, but not in the second.

So... am I doing something wrong? I didn't see an issue mentioning this, so probably it is me :-)