Abstract Base Classes Shouldn't Trigger Auto-"app_label" Generation
For some reason, importing an abstract base class causes Django to try and create an "app_label" for it. This isn't an issue, apparently, for ABCs defined in an app-level models.py module, but it causes an error (IndexError) if the ABC is in a top-level module in the python path. The current "fix" is to either move the ABC into an app's models.py file (not good for code re-use/separation) or supply a value for "app_label" in the ABC's class Meta. Perhaps adding a test to app_label generation that tests for _meta.abstract and skips on True might be a good idea?
Change History
(11)
| milestone: |
→ post-1.0
|
| Triage Stage: |
Unreviewed → Design decision needed
|
| milestone: |
post-1.0 → 1.0 maybe
|
| milestone: |
1.0 maybe → post-1.0
|
| Triage Stage: |
Design decision needed → Accepted
|
| Severity: |
→ Normal
|
| Type: |
→ Bug
|
| Component: |
Core (Other) → Database layer (models, ORM)
|
| Resolution: |
→ fixed
|
| Status: |
new → closed
|
Even if it is decided that all models should be defined within app-level modules it would be nice to have something better than an IndexError to point users at what the problem is. Attached is a very quick, minimally-tested patch with both changes included.