Opened 11 years ago
Closed 11 years ago
#21712 closed Cleanup/optimization (fixed)
Move admin.autodiscover() to AppConfig.setup()
Reported by: | Aymeric Augustin | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | app-loading |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
It doesn't belong to urls.py!
This probably requires shipping an apps.py with an AppConfig in the default project template and adding lots of documentation, including in the tutorial.
Change History (13)
comment:1 by , 11 years ago
Description: | modified (diff) |
---|
comment:2 by , 11 years ago
It may be more appropriate to put it in the admin AppConfig (once there's one, #21675) and to document how do disable it (via subclassing).
comment:3 by , 11 years ago
Summarizing a discussion with Marc on IRC:
- https://gist.github.com/mjtamlyn/8209667
- explain in the release notes to use
'django.contrib.admin.app.AdminConfig'
instead of'django.contrib.admin'
inINSTALLED_APPS
and removeadmin.autodiscover()
fromurls.py
.
comment:4 by , 11 years ago
PR submitted. There are at least three things to consider which are in the PR - including naming of the file, default project and testing.
comment:5 by , 11 years ago
I would change the default project to use the AdminConfig
. My guess is most people use the autodiscover method. People implementing their own AdminSite can read the documentation about it.
comment:6 by , 11 years ago
+1 to change the default project.
I'd keep the app.py
name. apps.py
would suggest several applications.
I'd also add verbose_name = _("Django administration")
.
comment:7 by , 11 years ago
The last point about the verbose_name
is tracked in #21675 as it covers all contrib apps.
comment:8 by , 11 years ago
Yes, we must change the default project template. We should also copy-paste the usual warnings in the tutorial for people who don't check properly what version they're using.
We've decided to always use apps.py
. Let's stick with that.
comment:9 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 11 years ago
It's impossible to make this change in the test suite because it relies on the admin autodiscovery not being run.
The bug8245
test app contains an invalid admin module that breaks autodiscovery.
comment:11 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
New PR: https://github.com/django/django/pull/2182
I think it's good to go but I would appreciate a proof-read. It's mostly a documentation patch.
comment:12 by , 11 years ago
I've only read the patch, but it looks good to me (except reported typos).
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
In fact, we don't have a good API for project-level startup code. Many projects have a "project app" for projectwide templates, staticfiles, etc. but the tutorial doesn't. This requires a bit more thought.