开发者

CSRF error when trying to log onto Django admin page with w3m on Emacs23

开发者 https://www.devze.com 2023-01-01 21:12 出处:网络
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 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 w开发者_运维知识库3m 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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消