[Django] #21131: Admin URL patterns are not aware of the app_namespace

2 views
Skip to first unread message

Django

unread,
Sep 20, 2013, 12:22:25 PM9/20/13
to django-...@googlegroups.com
#21131: Admin URL patterns are not aware of the app_namespace
-------------------------------+----------------------
Reporter: MarkusH | Owner: apollo13
Type: Bug | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+----------------------
Given these files:

{{{
# testapp/views.py
from django.core.urlresolvers import reverse
from django.http import HttpResponse

def testview(request):
rev = reverse('admin:testview', current_app='something')
return HttpResponse('Some Text %s' % rev)
}}}

{{{
# testapp/urls.py
from django.conf.urls import patterns, url

urlpatterns = patterns('',
url(r'^', 'testapp.views.testview', name='testview')
)
}}}

{{{
# testproject/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^foo/', include('testapp.urls', namespace='admin',
app_name='something')),
)
}}}


I'd expect that the view `testapp.views.testview` is still available when
resolving the `'admin:testview'` with the current_app set explicitly.
Instead I'm greeted with a `NoReverseMatch at /foo/` error:

{{{
Traceback:
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/handlers/base.py" in get_response
115. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/markus/Coding/django-namespace-test/testapp/views.py" in
testview
6. rev = reverse('admin:testview', current_app='something')
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py" in reverse
496. return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
*args, **kwargs))
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py" in _reverse_with_prefix
416. "arguments '%s' not found." % (lookup_view_s, args,
kwargs))

Exception Type: NoReverseMatch at /foo/
Exception Value: Reverse for 'testview' with arguments '()' and keyword
arguments '{}' not found.
}}}

Changing the order of the of the patterns in the `ROOTURL_CONF` makes the
admin inaccessible:

{{{
Traceback:
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/handlers/base.py" in get_response
115. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/contrib/admin/sites.py" in wrapper
219. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/contrib/admin/sites.py" in inner
198. current_app=self.name):
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py" in reverse
496. return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
*args, **kwargs))
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py" in _reverse_with_prefix
416. "arguments '%s' not found." % (lookup_view_s, args,
kwargs))

Exception Type: NoReverseMatch at /admin/
Exception Value: Reverse for 'logout' with arguments '()' and keyword
arguments '{}' not found.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21131>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 20, 2013, 12:23:30 PM9/20/13
to django-...@googlegroups.com
#21131: Admin URL patterns are not aware of the app_namespace
-------------------------------+------------------------------------

Reporter: MarkusH | Owner: apollo13
Type: Bug | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by MarkusH):

* cc: info@… (added)
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

I talked to apollo13 about this and therefore mark it as accepted.

--
Ticket URL: <https://code.djangoproject.com/ticket/21131#comment:1>

Django

unread,
Sep 20, 2013, 12:30:37 PM9/20/13
to django-...@googlegroups.com
#21131: Admin URL patterns are not aware of the app_namespace
-------------------------------+--------------------------------------

Reporter: MarkusH | Owner: apollo13
Type: Bug | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by apollo13):

* stage: Accepted => Unreviewed


Comment:

Um, MarkusH and I were talking about something slightly different,
resetting to unreviewed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21131#comment:2>

Django

unread,
Sep 20, 2013, 12:34:08 PM9/20/13
to django-...@googlegroups.com
#21131: Admin URL patterns are not aware of the app_namespace
-------------------------------+--------------------------------------

Reporter: MarkusH | Owner: apollo13
Type: Bug | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by timo):

Duplicate of #17914?

--
Ticket URL: <https://code.djangoproject.com/ticket/21131#comment:3>

Django

unread,
Sep 20, 2013, 12:39:20 PM9/20/13
to django-...@googlegroups.com
#21131: Admin URL patterns are not aware of the app_namespace
-------------------------------+--------------------------------------
Reporter: MarkusH | Owner: apollo13
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by MarkusH):

* status: new => closed
* resolution: => invalid


Comment:

Ok, I misread the docs. In the `ROOTURL_CONF` it must be

{{{
url(r'^foo/', include('testapp.urls', namespace='something',
app_name='admin')),
}}}

to make it work.

--
Ticket URL: <https://code.djangoproject.com/ticket/21131#comment:4>

Reply all
Reply to author
Forward
0 new messages