在此服务器django上找不到请求的URL

时间:2014-10-18 03:42:58

标签: python regex django django-urls

我正在关注youtube教程,并收到错误...

收到错误

The requested URL /hello was not found on this server.

网站/ urls.py

urlpatterns = patterns('',
    url(r'^hello/$', article.views.hello),
    ...
)

文章/ views.py

from django.shortcuts import render
from django.http import HttpResponse

def hello(request):
  name = 'mike'
  html = '<html><body> sup %s </body></html> ' %name
  return HttpRequest(html)

网站/ settings.py

INSTALLED_APPS = (
    ...
    'article',
)

1 个答案:

答案 0 :(得分:5)

请求网址/hello没有尾部斜杠(/)。您可以选择通过附加/

来使网址格式与?匹配
url(r'^hello/?$', article.views.hello),
相关问题