Thumbs up Tom. I didn't even bother to open the links you sent, I just finished the tutorial. The name of the link said it all, capturing-text-in urls.
I am most grateful. thanks all. I would have to read the links however to master these things. Regards. On Fri, Feb 18, 2011 at 4:20 PM, Tom Evans <tevans...@googlemail.com> wrote: > On Fri, Feb 18, 2011 at 3:04 PM, Dipo Elegbede <delegb...@dudupay.com> > wrote: > > > > Hi all, > > i am currently reading the django book and following the examples step by > step. > > I have a view defined as follows: > > from django.http import Http404, HttpResponse > > import datetime > > #def myhome(request): > > # message = """<html> > > # <head><title>MY HOME</title></head> > > # <body bgcolor='yellow'> > > # <center> > > # </center> > > # </body> > > # </html> > > # """ > > # return HttpResponse(message) > > # > > #def hello(request): > > # return HttpResponse("Hello World") > > # > > #def current_time(request): > > # now = datetime.datetime.now() > > # html = "<html><body>It is now %s.</body></html>" % 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 = "<html><body>In %s hour(s), it will be %s.</body></html>" % > (offset, dt) > > return HttpResponse(html) > > (All the commented area work just fine ) > > and I have a url.py like this: > > from django.conf.urls.defaults import * > > from mysite.views import * > > from django.contrib import admin > > admin.autodiscover() > > urlpatterns = patterns('', > > (r'^$', myhome), > > (r'^polls/', include('mysite.polls.urls')), > > (r'^hello/$', hello), > > (r'^time/$', current_time), > > (r'^time/plus/\d{1,2}/$', hours_ahead), > > ) > > when i try to run localhost:8000/time/plus/3, I get the following error: > > TypeError at /time/plus/4/ > > hours_ahead() takes exactly 2 arguments (1 given) > > Request Method: GET > > Request URL: http://localhost:8000/time/plus/4/ > > Django Version: 1.2.1 > > Exception Type: TypeError > > Exception Value: > > hours_ahead() takes exactly 2 arguments (1 given) > > Exception Location: > c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\handlers\base.py > in get_response, line 100 > > Python Executable: c:\Python26\python.exe > > Python Version: 2.6.4 > > Server time: Fri, 18 Feb 2011 15:51:57 +0100 > > My understanding of the error message is that I supplied, 1 argument when > the view function, hours_ahead was expecting 2 but really, i don't have a > hang of where to put the other argument. I am following the examples in the > book. > > I must be missing something, kindly help me out. > > thank you. > > > > > > > > These should help you: > > http://docs.djangoproject.com/en/1.2/topics/http/urls/#named-groups > > http://docs.djangoproject.com/en/1.2/topics/http/urls/#notes-on-capturing-text-in-urls > > Also, please configure your MUA to wrap lines at ~78 characters when > sending emails to mailing lists. > > Cheers > > Tom > > -- > 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com Mobile Banking Solutions | Transaction Processing | Enterprise Application Development -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.