Opened 9 years ago

Closed 9 years ago

#14505 closed (invalid)

Multiple Namespaces and reverse lookup does not work as advertised.

Reported by: dcurtis Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords: namespace application reverse
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


urlpatterns = patterns('',
    (r'^butter/', include(milkpost.urls, namespace="butter", app_name='milkpost')),
    (r'^newsletter/', include(milkpost.urls, namespace="newsletter", app_name='milkpost')),
    (r'^admin/', include(,

### milkpost.urls
def myview(request):
    return render_to_response('milkpost/main.html')

urlpatterns = patterns('',
        url(r'^myview', myview, name='myview'),

### main.html
{% load markup %}
    <title>main - milkbox</title>
<body align="center">
    {% url milkpost:myview %}

both urls: /newsletter/myview/ and /butter/myview/
print out /newsletter/myview/

As the following page points out,

two instances of the same app should be distinguishable. This does not happen though and can be very frustrating!

Change History (2)

comment:1 Changed 9 years ago by Frank Wiles

The docs aren't super clear, but after a quick read shouldn't your template just use {% url myview %} and then it will resolve properly inside each app? By using 'milkpost:myview' you're actually telling it to use the last installed instance ( i.e /newsletter/ ) here.

comment:2 Changed 9 years ago by Russell Keith-Magee

Resolution: invalid
Status: newclosed

This is working as designed. As Frank notes, 'milkpost:myview' is referencing the app namespace using the default name. If you want to differentiate them, you need to either use 'butter:myview' or 'newsletter:myview' to differentiate the instances, *or* pass in a current_app as part of the context when rendering the view.

As for the docs not being clear... I thought they were. They describe the step by step process, and gives an example as well. Suggestions on how to clarify the docs are welcome.

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