这是我的views.py:一个奇怪的Django错误
# Create your views here.
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.db import models
from display.forms import CodeForm
from display.forms import CodeFormSet
from ExamPy.questions.models import QuestionBase
def codepost(request):
if request.method == 'POST':
form = CodeFormSet(request.POST)
if form.is_valid():
titles = []
for i in range(0, self.total_form_count()):
form = self.forms[i]
title = form.cleaned_data['title']
if title in titles:
raise forms.ValidationError("Articles in a set must have distinct titles.")
titles.append(title)
return render_to_response('quesdisplay.html')
else:
form = CodeFormSet()
return render_to_response('quesdisplay.html', {'form':form})
因此,当我点击提交按钮,它应该显示quesdisplay.html没有任何形式的在里面。但是,它将我带到一些甚至不存在的联系页面。
错误:
The current URL, contact/, didn't match any of these.
我已经尝试了所有可能的方法来调试这一点,但它不可能的,因为没有任何东西在这个名为“接触”的痕迹。
编辑: 这是我得到的警告:
/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py:101: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.
warnings.warn("A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.")
[10/Nov/2011 05:34:17] "
你有没有为您在urls.py.“接触”条目 – danihp
是的。我有。没有一丝接触。即使在模板中也没有。模板有“。” – Hick
您是否检查过“联系人”的“quesdisplay.html”?在你的警告不出现'联系'。你在混合问题? – danihp