On Mon, 2009-08-10 at 11:28 -0700, nabucosound wrote: > Hi all: > > I have a URLconf url entry like this: > > > url( > regex=r'^(?P<category>\w+)/(?P<slug>[-\w]+)/$', > view='show_post', > name='show_post', > kwargs={'msg': None}, > ), > > > and I want to call it with HttpResponseRedirect and reverse(): > > > filters = {'category': post.category.name, 'slug': post.slug} > return HttpResponseRedirect(reverse('show_post', kwargs=filters)) > > > but I am getting this error: > > > NoReverseMatch at /commentposted/first-post/ > > Reverse for 'show_post' with arguments '()' and keyword arguments > '{'category': u'django', 'msg': 'Your comment has been posted', > 'slug': u'first-post'}' not found. >
[...] > Is there any way to pass th reverse() function extra optional > parameters that the url define? Or am I crazy? No, you can't do that. By the way, the extra arguments you are passing in aren't *optional* -- they are simply not required. There is not situation in which they will be used to construct the URL. You can only pass in parameters that are present in the URL pattern. There are a bunch of technical reasons for this (including handling optional arguments and precise error reporting), so it's not an arbitrary decision. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---