Opened 12 years ago

Last modified 9 years ago

#17716 closed Cleanup/optimization

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

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 (last modified by Aymeric Augustin)

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 (1)

comment:1 by Aymeric Augustin, 12 years ago

Description: modified (diff)

Fixed formatting (please use preview).

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