Don't mix *args and **kwargs in call to reverse()!

982 views
Skip to first unread message

Adrián Ribao

unread,
Sep 1, 2008, 7:29:26 AM9/1/08
to Django users, ari...@gmail.com
Change in rev:8760 introduced this exception: "Don't mix *args and
**kwargs in call to reverse()!"

-- django/trunk/django/core/urlresolvers.py --
...
def reverse(self, lookup_view, *args, **kwargs):
if args and kwargs:
raise ValueError("Don't mix *args and **kwargs in call to
reverse()!")
...
Why is not possible to mis args and kwargs? I don't understand the
reason, and all of my reverse funcions will fail because of this.

I'd like some help with this.

Thank you.

Adrián Ribao

unread,
Sep 1, 2008, 10:47:41 AM9/1/08
to Django users
I'll write an example of the problem. All my urls are prepared
following the best SEO rules, so in many places I have urls like:
(r'^(.*)-f(?P<id>\d+)\.html$','view_photo')

this would make the url:
my-photo-f2.html

I get the url using:
reverse('app.views.view_photo', args=[slugify(photo.title),],
kwargs={'id':id} )
(Note: I don't want to use a slug field.)

Now this won't work. Well, IMHO this is a bug, I don't see the point.
Besides this makes rev:8760 backwards incompatible and it wasn't
suppose to.

I really need some more information about this.

Thank you.

Håkan W

unread,
Oct 30, 2008, 11:11:19 AM10/30/08
to Django users
I just hit this too. There seems to be no information or hint in the
docs about this (neither in the docs about reverse or permalink), from
what I can find...

/Håkan
Reply all
Reply to author
Forward
0 new messages