Opened 10 years ago
Closed 10 years ago
#24776 closed Cleanup/optimization (fixed)
apps.get_app_config() could give better errors on fully-qualified package names
Reported by: | Peter Inglesby | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Running eg ./manage.py dumpdata django.contrib.auth
fails with CommandError: Unknown application: django.contrib.auth
. Instead, you need to call the command with just auth
.
This is because it calls through to apps.get_app_config
which does not expect a fully-qualified package name.
There is a similar problem with other management commands that take an app's name.
There are a handful of approaches to fixing this:
apps.get_app_config
should split a package name on dots, throw away all but the last token, and use this for looking up the app. I've not thought through all the consequences of this -- could an app name legitimately contain dots?- As for 1, but only if the package name begins
django.contrib
. - When
apps.get_app_config
raises aLookupError
, it could check to see whether its argument contains dots, and its message could be something likeNo installed app with label 'x.y.z'. Did you mean 'z'?
. - Whenever a management command calls
apps.get_app_config
, it could strip offdjango.contrib.
if present.
I'm happy to code up a fix if/when the right approach is settle on.
Change History (3)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Summary: | apps.get_app_config does not handle fully-qualified package names → apps.get_app_config() could give better errors on fully-qualified package names |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Version: | 1.8 → master |
Note:
See TracTickets
for help on using tickets.
These commands are documented to take app labels in argument rather than app names.
Option 3 is a decent idea but it should be implemented by inspecting the app cache to figure out if there's an app with the provided name and find its label. This cannot be done simply by splitting on dots because it's possible to give any label to an app with a customized AppConfig class.