私はThe Django Bookのチュートリアルに従っています。このエラーが発生するのはうんざりです。現在のURLは、これらと一致しませんでした。 私urls.pyがある:Django:現在のURLは、これらのいずれとも一致しません
from django.conf.urls import include, url
from django.contrib import admin
from mysite.views import hello, current_datetime, hours_ahead
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^hello/$', hello),
url(r'time/$', current_datetime),
url(r'^time/plus/(\d{1,2})$', hours_ahead),
]
とviews.pyは以下のとおりです。
def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)
def hours_ahead(request, offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
dt = datetime.datetime.now() + datetime.timedelta(hours = offset)
html = "In %s hour it will be %s" %(offset, dt)
return HttpResponse(html)
と私は取得していますエラーは次のとおりです。mysite.urlsで定義されているのURLconfを使用して
、 Djangoは次の順序でこれらのURLパターンを試しました:
1.^admin/
2.^hello/$
3. time/$
4. ^time/plus/(\d{1,2})$
現在のURLは、これらのいずれとも一致しませんでした。