I've opened a ticket for improving the NoReverseMatch error: https://code.djangoproject.com/ticket/17076
However, I'd still like to improve the documentation regarding which patterns can be reversed. I don't fully understand the limitations myself yet. 1. Can we provide an example of a pattern containing "|" that doesn't work? I've successfully reversed the pattern r'^fruit/(bananas|apples) $' above. 2. Can we give a more precise description of the limits of reversible patterns? Is it just that the arguments / keyword arguments must match up (looking at https://github.com/django/django/blob/master/django/core/urlresolvers.py#L364 this seems to be only obvious limitation)? On Oct 12, 4:13 pm, Wilfred Hughes <wilf...@potatolondon.com> wrote: > > > >>> reverse('i_dont_exist') > > > NoReverseMatch: Reverse for 'i_dont_exist' with arguments '()' and > > > keyword arguments '{}' not found. > > > > In this case, it would be nicer to have something like: > > > > NoURLPattern: No patterns specified for 'i_dont_exist'. > > > Just on this point, I must disagree. For instance, consider if you > > have a URL named 'i_dont_exist', and the URL pattern has two > > positional arguments. > > Ah, sorry. I've been unclear. My point here is that when there /isn't/ > a URL with that name. It would be good to distinguish between having > no regexes and not being able to reverse the regex. > > So, if I have an URL: > > url(r'^fruit/(bananas|apples)$', some_view, name='fruit'), > > And I make a spelling mistake: > > >>> reverse('rfuit', args=['bananas']) > > I would like some hint that the problem isn't in my regex. The two > options I'm proposing are: > > NoURLPattern: No patterns specified for 'rfuit'. > > Or: > > NoReverseMatch: Reverse for 'rfuit' with arguments '()' and > keyword arguments '{}' not found (patterns tried: []). -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.