views:

131

answers:

1

I normally use Firefox and have had no problems with the admin page on my Django website. But I use Emacs23 for writing my posts, and wanted to be able to use w3m in Emacs to copy the stuff across. When I try to log into my admin pages, it gives the CSRF error:

CSRF verification failed. Request aborted.

Help

Reason given for failure:

    No CSRF or session cookie.

...

Is there a way that I could get w3m to work with my admin page? I am not sure if the problem lies with the way the admin is set up on Django or with the Emacs or w3m settings.

A: 

Django 1.2 requires a CSRF token by default for all form POSTs. I don't think there's a way to get the token via an API call in order to be able to to post from Emacs.

You could just remove the effects of the @protect_csrf decorator on the django-bundled view by copying and tweaking that view's code to make a bespoke version of the view that doesn't have the decorator.

I'm guessing from your limited info above that it's a non-protected version of contrib.auth's login() method that you going to need to replicate here, and I'd recommend you put access to this method under a rather non-obvious url route to maintain some semblance of CSRF for the outside world. (ie, don't override the /login/ path - wire up access to this view somewhere else)

stevejalim
I've realized that all forms give me the same results on w3m, and so I am assuming that my problem is with w3m and it's settings rather than Django.
Vernon