On Saturday, 20 August 2011 20:20:12 UTC+1, Joshua Russo wrote: > > I setup this patter in url.py > > url(r'^events/(?P<year>\d{4})/(?P<month>\d{2})/$', events, > name="eventsMonth") > > in my template I have this tag > > {% url eventsMonth year=month.prev.year month=month.prev.month %} > > but I keep getting > > Caught NoReverseMatch while rendering: Reverse for 'eventsMonth' with > arguments '()' and keyword arguments '{'month': 7, 'year': 2011}' not found. > > I traced the problem into the reverse() code and the logic goes all the way > to the end, when the following statement from line 325 of > core/urlresolvers.py fails and I can't figure out why > > if re.search(u'^%s' % pattern, candidate, re.UNICODE): > > The pattern is > 'events/(?P<year>\\d{4})/(?P<month>\\d{2})/$' > and the candidate is > u'events/2011/7/' > > Why doesn't that regular expression match? What am I doing wrong? >
Because there's only one digit in the month (7), and it's expecting two. Either change your code to pad the month to two digits, or change the regex to /(?P<month>\d{1,2})/$ -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/588gFtIFPKUJ. 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.