Opened 13 years ago

Last modified 10 years ago

#17716 closed Cleanup/optimization

include(arg, namespace=None, app_name=None) replace app_name with namespace — at Initial Version

Reported by: blackip@… Owned by: nobody
Component: Core (URLs) Version: dev
Severity: Normal Keywords: include reverse url
Cc: Florian Apolloner Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When we register urls - we can specify app_name like this

urlpatterns = patterns(,

url(r'inventory/', include('inventory.urls', app_name='inventory')),
url(r'
cart/', include('cart.urls',app_name='cart')),

Then we can use reverse method or {% url cart:cart %} to generate url.

But it does not work - got NoReverseMatch at /cart/

u'cart' is not a registered namespace
Request Method: GET
Request URL: http://localhost:8000/cart/
Django Version: 1.4a1

When I register urls like this

url(r'inventory/', include('inventory.urls', namespace='inventory')),
url(r'
cart/', include('cart.urls',namespace='cart')),

IT DOES WORK !

According to documentation format for urls should be

{% url app_name:view_name %}
but actual format is
{% url namespace:view_name %}

I think this is a bug

The source of bug may be in

file /usr/local/lib/python2.7/site-packages/django/conf/urls/init.py
function include(arg, namespace=None, app_name=None)

It returns tuple (urlconf_module, app_name, namespace)
It looks like it should be (urlconf_module, namespace, app_name)

Change History (0)

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