Hello, you need to make 'year' argument optional: def student_reports(request, year=None): year = year or datetime.date.today().year ...
Another option could be passing extra option to you view function: https://docs.djangoproject.com/en/1.4/topics/http/urls/#passing-extra-options-to-view-functions Cheers, Tom Dne Mon, 22 Oct 2012 15:24:51 +1200 Lachlan Musicman <data...@gmail.com> napsal(a): > Hola, > > I have data across multiple years. > > I want to run reports on a per year basis, so I have in my urls: > url(r'^students/reports/(?P<year>\d{4})/$', student_reports, > name='student_reports'), > > etc. > > What I want to know though, is how to have this in the urls: > url(r'^students/reports/$', student_reports, name='student_reports'), > > defaulting to the year it's run. (ie, year = datetime.date.today().year) > > I thought about passing extra options, but it feels like overkill? > > I have in my views.py: > > def student_reports(request, year): > if not year: > year = datetime.date.today().year > yada yada > > > but this is failing on not enough arguments... > > > Cheers > L. > > z` S pozdravem Tomáš Ehrlich Email: tomas.ehrl...@gmail.com Tel: +420 608 219 889 Jabber: elv...@jabber.cz "Půjdu kamkoliv, pokud je to kupředu." - J. London -- 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.