Lots of people correctly suggest using named url patterns and the {% url %} template tag to obtain a URL. The concept is great and follows the DRY principle. However, I believe that if a pattern has an "include(<filename>)" instead of a view function, the existing mechanism fails. An example of the problem, using three files in a standard Django project:
----------file views.py---------- def func: pass ----------end file---------- ----------file urls.py---------- from django.conf.urls.defaults import * from views import func urlpatterns = patterns('', (r'^drink/', 'views.func', {'myname':'drink'}, 'drink'), (r'^eat/', include('urls2'), {'myname':'eat'}, 'eat'), url(r'^exercise/', func, kwargs={'myname':'exercise'}, name='exercise'), url(r'^sleep/', include('urls2'), kwargs={'myname':'sleep'}, name='sleep'), ) ----------end file---------- ----------file urls2.py---------- from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^$', 'views.func'), ) ----------end file---------- Invoking "manage.py shell", these are the results of calling reverse() (which I understand from the documentation works very much the same as {% url %}: >>> from django.core.urlresolvers import reverse >>> reverse('drink') '/drink/' >>> reverse('eat') Traceback (most recent call last): File "<console>", line 1, in ? File "c:\django\trunk\django\core\urlresolvers.py", line 297, in reverse return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kw args)) File "c:\django\trunk\django\core\urlresolvers.py", line 284, in reverse raise NoReverseMatch NoReverseMatch >>> reverse('exercise') '/exercise/' >>> reverse('sleep') Traceback (most recent call last): File "<console>", line 1, in ? File "c:\django\trunk\django\core\urlresolvers.py", line 297, in reverse return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kw args)) File "c:\django\trunk\django\core\urlresolvers.py", line 284, in reverse raise NoReverseMatch NoReverseMatch Is there a workaround for this issue? Am I doing something incorrectly? Should I file a ticket? Graham --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---