3
我的1.2.3 django站点使用contrib.auth
,我的目标是使用wkhtmltopdf命令行来打印登录专用页面wkhtml can handle this situation。从Django站点的shell登录
所以我测试了登录与卷曲,可以肯定这是可能的
的问题是,我总是得到一个403 CSRF(或饼干)保护错误。
我试着做禁用CSRF与第二登录视图:
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.views import login
@csrf_exempt
def fakelogin(request, template_name='registration/login.html'):
return login(request, template_name)
这一新观点按预期工作。然后,当提到here:
curl -c cookies.txt http://dev.local:8000/fakelogin/
curl -c cookies.txt -d login.txt http://dev.local:8000/fakelogin/
与包含的login.txt username=Bob&password=secret&next=/page_to_print/id/
但403 CSRF错误仍然显示了(我真的不知道,如果是在涉及到跨站请求伪造或会话cookie他点...)
禁用CSRF不是一种选择。 curl只是测试登录成功的简单方法,当然,我也可以使用斜纹。 – 2011-02-07 13:35:40