I'm baffled.  I'm just getting started with django and am reading the
'Django Book'.  In chapter 3 I'm told,

- Make a file called views.py that contains:

from django.http import HttpResponse
import datetime

def current_datetime(request):
        now = datetime.datetime.now()
        html = "<html><body>It is now %s.</body></html>" % now
        return HttpResponse(html)

- then edit your urls.py to contain

from django.conf.urls.defaults import *

urlpatterns = patterns('',
        (r'^now/$', current_datetime),
)

then start the server and go to http://myserver:8080/now/

I immediately get

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  68. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
resolve
  160. for pattern in self.urlconf_module.urlpatterns:
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
_get_urlconf_module
  177. self._urlconf_module = __import__(self.urlconf_name, {}, {},
[''])

  NameError at /now/
  name 'current_datetime' is not defined

What am I missing?  I tried both the stable build, and the latest svn
with the same results


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to