I am following the tutorials on The Django Book, and I am tired of getting this error - The current URL, , didn't match any of these. my urls.py is:
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),
]
and views.py is:
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)
and error I'm getting is:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
1.^admin/
2.^hello/$
3. time/$
4. ^time/plus/(\d{1,2})$
The current URL, , didn't match any of these.