현재 날짜 및 시간 오프셋을 특정 시간으로 표시하는보기를 만들고 있습니다. 목표는 페이지/시간/더하기/1에 대한 사이트를 디자인하는 것입니다. 한 시간에 날짜와 시간을 표시하고 페이지/시간/더하기/2 /는 두 시간에 날짜와 시간을 표시하고 페이지/시간/더하기/3 /은 3 시간 내에 날짜와 시간을 표시합니다. 이 views.py 내 기능입니다 :Django의 동적 URL
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(s), it will be %s." % (offset, dt)
return HttpResponse(html)
이 내 url.py 파일의 내용이다 :
from django.conf.urls import patterns, include, url
from aplicacion1.views import hours_ahead
urlpatterns = patterns('',
url(r'^time/plus/(d{1,2})/$', hours_ahead),)
views.py의 패턴은 숫자 만 하나 개 또는 두 개의 숫자를 받아 들여야한다 장고는 "페이지를 찾을 수 없습니다"라는 오류를 표시해야합니다. http://127.0.0.1:8000/time/plus/(no hours)
URL도 404 오류가 발생합니다. 오류가 나는 무엇을 만들고 있어요입니다
Page not found (404)
Request Method: GET
Request URL:
http://127.0.0.1:8000/time/plus/24/
Using the URLconf defined in cibernat.urls, Django tried these URL patterns, in this order:
^$
^time/$
^time/plus\d+/$
^admin/doc/
^admin/
The current URL, time/plus/24/, didn't match any of these.
: 나는 서버를 실행하고 http://127.0.0.1:8000/time/plus/24/
같은 URL에 액세스하려고 할 때, 나에게 다음과 같은 오류 알려줍니다? 나는