Opened 16 years ago

Last modified 14 years ago

#8764 closed

Mixing args and **kwargs in reverse() function — at Initial Version

Reported by: Adrian Ribao Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords: reverse function exception
Cc: aribao@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Changeset [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()!")


[8760] was suppose to be backwards compatible but is not. My question is:
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'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 any reason why the reverse function shouldn't work the same way as it did before. Aplying a patch and make the funcion so limited is not appropiated.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top