Django:CSRF cookie不是s

2024-09-30 01:21:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在我的django项目中发布一个表单,导致“CSRF cookie not set.”错误。在

在视图.py在

from django.shortcuts import render
from django.template import RequestContext
from pyBikeMilesApp.models import Eintrag
from django.template.context_processors import csrf

# Create your views here.
def index(request):
  if request.method == 'POST':
    print(request.POST)

  # Get all posts from DB
  eintraege = Eintrag.objects
  return render(request,'index.html',{'Eintraege': eintraege})

索引.html在

^{pr2}$

在生成的页面中,我可以看到csrf输入字段:

<input type='hidden' name='csrfmiddlewaretoken' value='zzRnENjz6wrUP8Op8IVOIDsUVvclY37k' />

有什么办法,怎么解决?在


Tags: 项目djangofromimport表单indexrequesthtml

热门问题