#14007 closed New feature (fixed)
Automatically discover models within a package without using the app_label Meta attribute
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2 |
Severity: | Normal | Keywords: | sprintdec2010 package models model |
Cc: | aav, django@…, timograham@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Automatically figure out the app_label for a model by looking one level up from the package or module named 'models'.
If no such package or module exists, fall back to the behavior of looking one level up from
the module the model is defined in.
For 'django.contrib.sites.models', this would be 'sites'.
For 'geo.models.places' this would be 'geo'.
For 'polymorphic.polymorhpic_model' this would be 'polymorphic'.
This allows organization of models within a package named 'models' without having to specify the app_label Meta attribute for each model.
Attachments (3)
Change History (15)
by , 14 years ago
Attachment: | model_package_automatic_discovery.diff added |
---|
comment:1 by , 14 years ago
Owner: | changed from | to
---|
comment:2 by , 14 years ago
Needs documentation: | set |
---|---|
Owner: | changed from | to
Patch needs improvement: | set |
by , 14 years ago
Attachment: | 14007_model_package_automatic_discovery.diff added |
---|
Cleanly-applying version of the patch above.
comment:3 by , 14 years ago
Keywords: | sprintdec2010 added |
---|---|
Patch needs improvement: | unset |
Triage Stage: | Unreviewed → Accepted |
The tests for the entire suite pass with the patch. The functionality works as advertised.
I've also tested it every which way I could think of, including plugging it into a giant project that uses models modules extensively and does some advanced customisation of the admin, and it still works.
by , 14 years ago
Attachment: | 14007_fix_with_docs.diff added |
---|
The above patch with appropriate documentation changes.
comment:4 by , 14 years ago
Needs documentation: | unset |
---|
comment:5 by , 14 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | set |
Severity: | → Normal |
Type: | → Uncategorized |
14007_fix_with_docs.diff fails to apply cleanly on to trunk
comment:6 by , 14 years ago
Type: | Uncategorized → New feature |
---|
comment:8 by , 13 years ago
Cc: | added |
---|---|
UI/UX: | unset |
comment:9 by , 12 years ago
Cc: | added |
---|
comment:10 by , 11 years ago
Cc: | added |
---|---|
Patch needs improvement: | unset |
comment:11 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Please upload a new patch fixing the title of the files.
A bug in Trac makes it difficult to see which file the patches belong (try -A1 -B1 and double check the file names).