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