I am following the third chapter in the Django book : http://www.djangobook.com/en/2.0/chapter03.html
I am trying to change my urls.py and views.py but nothing seems to be happening when I alter the urls.
The error I get does not seem consistent with what I have changed my URLS.oy too. I have commeted out everything that is not what I am trying to implement:
from django.http import HttpResponse import datetime def hello(request): return HttpResponse("Hello world") def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html)
from django.conf.urls.defaults import patterns, include, url from django.contrib import admin from mysite.views import hello, current_datetime urlpatterns = patterns('', # This is going to be our home view. # We'll uncomment it later url(r'^hello/$', hello), url(r'^time/$', current_datetime) ) """ admin.autodiscover() urlpatterns += patterns('', url(r'^todo/', include('mysite.todo.urls')), url(r'^polls/', include('mysite.polls.urls')), ) urlpatterns += patterns('', url(r'^$', 'mysite.myapp.views.home', name='home'), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), ) # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), """
and the error:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^$ [name='home'] ^myapp/ ^todo/ ^polls/ ^admin/ The current URL, hello, didn't match any of these.
I dont see how this error can be correct as I have modified the URLS.PY to make them an error. If you can advise me on how to get my hello world app working I would appreciate it. I think the tutorial is for django 1.4 and this site runs 1.3 so maybe that will help. Any help is appreciated I have struggling with this error for too long. thanks.