I am sure this is an incredibly stupid error that is staring me in the
face, but I do not know what it is. On the example where you make an
hours_ahead view. I created the view in views.py and I added the
pattern to urls.py, but when I try to go to a pages to test such as
http://127.0.0.1:8000/time/plus/12/ I receive an error of "name
'hours_ahead' is not defined"
views.py--
from django.http import HttpResponse
import datetime
def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." %
now
return HttpResponse(html)
def hours_ahead(request, offset):
offset = int(offset)
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
html = "In %s hour(s), it will be %s." %
(offset, dt)
return HttpResponse(html)
urls.py--
from django.conf.urls.defaults import *
from mysite.views import current_datetime
urlpatterns = patterns('',
(r'^time/$', current_datetime),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
)
Does anyone see what I did wrong?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---