没有条目匹配查询 django
好吧,我有一个非常奇怪的问题。我已经像这样映射了我的网址:
url(r'^contact/$', 'blog.views.contact'),
但是每当我转到/contact/时,我都会收到404,我已经多次检查了我的re,但无法弄清楚这里的问题是什么..
这是相关的联系人视图:
def contact(request):
"""
"""
if request.method == "POST":
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail("New contact form submission!", cd["message"],
"[email protected]", cd["email"])
return redirect('blog.views.index')
else:
form = ContactForm()
return render_to_response("contact.html", {"form" : form},
context_instance = RequestContext(request))
Okay so I've really weird problem. I've mapped my url like this :
url(r'^contact/
however whenever I go to /contact/, I get a 404, I've cheked my re several time and can't figure out what is the problem here..
Here's contact view if it's relevant :
def contact(request):
"""
"""
if request.method == "POST":
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail("New contact form submission!", cd["message"],
"[email protected]", cd["email"])
return redirect('blog.views.index')
else:
form = ContactForm()
return render_to_response("contact.html", {"form" : form},
context_instance = RequestContext(request))
, 'blog.views.contact'),
however whenever I go to /contact/, I get a 404, I've cheked my re several time and can't figure out what is the problem here..
Here's contact view if it's relevant :
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几种可能性:
1) 有问题的 URL 文件根本没有被包含在内。通过确认同一文件中的其他 URL 是否正常工作来测试这一点。
2) 另一种早期模式是匹配您的 URL,然后在视图中抛出 404。通过将此模式移至根 URL 中的第一个模式来测试这一点。
3)您的视图中的某些内容抛出了 404。根据您所包含的代码,这看起来不太可能,但可以通过用简单的东西(例如
direct_to_template
)替换视图来测试这一点A few possibilities:
1) The URLs file in question is not getting included at all. Test this by confirming that other URLs in the same file are working.
2) Another earlier pattern is matching your URL and then throwing a 404 in the view. Test this by moving this pattern to be the first pattern in your root URLs.
3) Something in your view is throwing the 404. This doesn't look likely, based on the code you've included, but test this by replacing the view with something simple, like a
direct_to_template