Opened 8 years ago

Closed 2 years ago

#8108 closed Bug (fixed)

Abstract Base Classes Shouldn't Trigger Auto-"app_label" Generation

Reported by: brooks.travis@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: app_label, abstract-base-class
Cc: brooks.travis@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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 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 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?

Attachments (1)

8108.diff (1.6 KB) - added by evan_schulz 8 years ago.

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by evan_schulz

comment:1 Changed 8 years ago by evan_schulz

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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.

comment:2 Changed 8 years ago by adamfast

  • milestone set to post-1.0
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 8 years ago by mtredinnick

  • milestone changed from post-1.0 to 1.0 maybe

I don't like the patch (we should just not have an app name for ABCs), but the idea has merit because it allows more flexible design. Worth doing for 1.0 if we have time.

comment:4 Changed 8 years ago by jacob

  • milestone changed from 1.0 maybe to post-1.0
  • Triage Stage changed from Design decision needed to Accepted

Malcolm now says that we don't have time.

comment:5 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:6 Changed 5 years ago by lukeplant

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:8 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:9 Changed 3 years ago by aaugustin

  • Component changed from Core (Other) to Database layer (models, ORM)

comment:10 Changed 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

This problem came up during the app-loading refactor and was fixed. See #21794 for details.

Note: See TracTickets for help on using tickets.
Back to Top