On Wed, Oct 12, 2011 at 12:56 PM, Wilfred Hughes <wilf...@potatolondon.com> wrote: > It would be really good if we could improve the errors provided when > Django can't do reverse(). > > For example: > > >>> 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. If I attempted to reverse() that name, but don't supply the required arguments, then the existing error clearly explains why no match was found - there were no arguments passed. The proposed error message would not explain why, and would be misleading - there is a URL pattern, but it is not applicable without additional arguments. The most common time I encounter this is when using {% url %} in a template. You pass in the appropriate positional/named arguments, but if the variables you pass in don't correspond to valid variables, you don't want to be told that the reason it couldn't reverse the URL was because there was no such pattern. Cheers Tom -- 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.