[Django] #21132: AdminSite cannot handle different namespace

9 views
Skip to first unread message

Django

unread,
Sep 20, 2013, 1:02:34 PM9/20/13
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+--------------------
Reporter: MarkusH | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Assume you have a custom admin inheriting from
django.contrib.admin.sites.AdminSite and you want to run it with its own
namespace:

{{{
# testproject/urls.py
from django.conf.urls import patterns, include, url
from django.contrib.admin.sites import AdminSite

my_admin = AdminSite(name='name', app_name='app_name')

urlpatterns = patterns('',
url(r'^admin/', include(my_admin.urls)),
)
}}}

This is going to fail with the following error:

{{{
Traceback (most recent call last):
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py", line 482, in reverse
extra, resolver = resolver.namespace_dict[ns]
KeyError: 'admin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/contrib/admin/sites.py", line 219, in wrapper
return self.admin_view(view, cacheable)(*args, **kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/contrib/admin/sites.py", line 198, in inner
current_app=self.name):
File "/home/markus/.venvs/django-namespace-test/lib/python3.3/site-
packages/django/core/urlresolvers.py", line 492, in reverse
key)
django.core.urlresolvers.NoReverseMatch: 'admin' is not a registered
namespace
}}}

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

Django

unread,
Sep 20, 2013, 1:04:25 PM9/20/13
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+------------------------------------
Reporter: MarkusH | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
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 apollo13):

* needs_better_patch: => 0
* component: Uncategorized => contrib.admin
* needs_tests: => 0
* version: 1.5 => master
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

The whole admin is currently built on the idea that the app is named
admin, I think we should just deprecate the app_name argument.

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

Django

unread,
Nov 2, 2013, 10:07:08 AM11/2/13
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+------------------------------------
Reporter: MarkusH | Owner: vajrasky
Type: Bug | Status: assigned

Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* owner: nobody => vajrasky
* status: new => assigned
* has_patch: 0 => 1


Comment:

This ticket is quite big (at least for me). This PR is the first step to
fix this issue. https://github.com/django/django/pull/1845

There are more to be done. You can check by:
$ grep -R "admin:" *

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

Django

unread,
Nov 13, 2013, 8:00:04 PM11/13/13
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+------------------------------------
Reporter: MarkusH | Owner: vajrasky
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by glarrain):

Replying to [comment:1 apollo13]:


> The whole admin is currently built on the idea that the app is named
admin, I think we should just deprecate the app_name argument.

I disagree. I think we should fix it. Hardcoded admin strings all around
are, IMO, a very bad idea.

On the other hand, I'm not really an expert in app and URL namespacing so
take my comment with a grain of salt.

PS: this topic is currently discussed in the mailing list
https://groups.google.com/forum/#!topic/django-developers/pc5A3qrvITQ

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

Django

unread,
Apr 18, 2014, 7:48:55 AM4/18/14
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+------------------------------------
Reporter: MarkusH | Owner: vajrasky
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by vzima):

+1 for removal of `app_name` argument. It mostly just confuses developers
since it can not be changed to anything else, see #19002, #19554, #22418.

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

Django

unread,
Aug 13, 2014, 3:25:52 PM8/13/14
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+-------------------------------------
Reporter: MarkusH | Owner: timgraham

Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* owner: vajrasky => timgraham


Comment:

[https://github.com/django/django/pull/3060 PR] to remove the `app_name`
argument. There seems no need for a deprecation since the functionality
doesn't work and isn't documented.

--
Ticket URL: <https://code.djangoproject.com/ticket/21132#comment:5>

Django

unread,
Aug 14, 2014, 9:07:11 AM8/14/14
to django-...@googlegroups.com
#21132: AdminSite cannot handle different namespace
-------------------------------+-------------------------------------
Reporter: MarkusH | Owner: timgraham
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"cf79b57ad09c145b82ccaab798d88958316027cf"]:
{{{
#!CommitTicketReference repository=""
revision="cf79b57ad09c145b82ccaab798d88958316027cf"
Fixed #21132 -- Removed the useless app_name argument to AdminSite.

Thanks MarkusH for the report and Florian for review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21132#comment:6>

Reply all
Reply to author
Forward
0 new messages