[Django] #21794: No warning should be raised when defining an abstract model with no app_label

30 views
Skip to first unread message

Django

unread,
Jan 16, 2014, 10:30:57 PM1/16/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database | Keywords: app-loading
layer (models, ORM) | Has patch: 1
Severity: Normal | Needs tests: 0
Triage Stage: | Easy pickings: 1
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Since those models are never registered and meant to be used by different
apps it doesn't make much sense to raise a warning in this case.

I think this case was just overlooked when Aymeric refactored app-loading.

Attaching a patch fixing the issue and removing an extra space between
`in` and `INSTALLED_APPS` in the warning message.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 17, 2014, 2:51:55 AM1/17/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* owner: nobody => aaugustin
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:1>

Django

unread,
Jan 18, 2014, 6:57:47 AM1/18/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master

Component: Database layer | Resolution:
(models, ORM) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

This deprecation aims at getting rid of the legacy "look one level up from
the package or module named 'models'" behavior. (In the face of ambiguity,
refuse the temptation to guess.)

app_label is primarily used to determine which application the model
should be attached to in the app registry. Since abstract models aren't
registered, they may work without one, although I'm not sure if there are
other consequences.

When this logic goes away, what app_label do we set for abstract models
that aren't in an installed app and don't have an explicit app_label?
`Options` has a default value of `None`. I assume we can use that.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:2>

Django

unread,
Jan 18, 2014, 6:59:10 AM1/18/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* easy: 1 => 0
* stage: Unreviewed => Accepted


Comment:

I'm attaching a patch that keeps a warning for abstract models (because
the behavior will change) but uses a different message.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:3>

Django

unread,
Jan 18, 2014, 7:36:11 AM1/18/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin

Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:4>

Django

unread,
Jan 18, 2014, 12:23:29 PM1/18/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Database layer | Resolution: fixed

(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Aymeric Augustin <aymeric.augustin@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"2f65b8e14c03a6b43c11d5de791b8d4d91721777"]:
{{{
#!CommitTicketReference repository=""
revision="2f65b8e14c03a6b43c11d5de791b8d4d91721777"
Fixed #21794 -- Adjusted warning for abstract models.

As far as I can tell, they don't need an app_label.

Thanks Simon Charette for the report and the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:5>

Django

unread,
Feb 1, 2014, 1:43:51 PM2/1/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"4a488c14833000eaf5d2b4c2787b6a61c99a4f53"]:
{{{
#!CommitTicketReference repository=""
revision="4a488c14833000eaf5d2b4c2787b6a61c99a4f53"
Silenced a spurious warning.

Thanks Timo for the report. Regression from 2f65b8e1. Refs #21794.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:6>

Django

unread,
Jun 8, 2014, 3:30:16 PM6/8/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

In fact, this problem existed before the app-loading refactor, see #8108.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:7>

Django

unread,
Sep 21, 2014, 10:04:47 PM9/21/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by gregplaysguitar):

I'm getting this warning when inheriting from an abstract base class in
Django 1.7, but if I set {{{app_label = None}}} in my abstract base class,
it causes another error, because all the model classes inheriting from it
now think they are in an app labelled {{{None}}}. Does this mean that as
of Django 1.9 *all* model classes will need to have {{{app_label}}}
explicitly set? If not I don't think there should be any warning for an
abstract base class in this case, because there's no solution.

I may have misunderstood something here, so please feel free to set me
straight!

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:8>

Django

unread,
Oct 2, 2014, 10:14:24 PM10/2/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:

(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gregplaysguitar):

* status: closed => new
* resolution: fixed =>


Comment:

Hi, I'm going to reopen this because I'm pretty confident the issue is
still valid. At the moment I'm getting screeds of RemovedInDjango19
warnings and have no way to turn them off. It doesn't make sense for
abstract models to have an app_label, because by their very nature they
can be used in multiple apps.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:9>

Django

unread,
Oct 2, 2014, 10:16:32 PM10/2/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by gregplaysguitar):

Alternately, the warning could stay in place but the current behaviour
where app_label = None is inherited from the abstract model's Meta class
would have to change.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:10>

Django

unread,
Oct 3, 2014, 11:16:22 AM10/3/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by collinanderson):

Actually, could you re-close this ticket and open a new one? Your issue is
related to this one but I think it's a slightly different issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:11>

Django

unread,
Oct 5, 2014, 4:42:05 PM10/5/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: app-loading | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by gregplaysguitar):

Hi Collin, the original submitted patch would have solved my problem, so I
don't really think it's a separate issue - I will do as you suggest though
and bring it up on django-developers.

Thanks,
Greg

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:12>

Django

unread,
Oct 7, 2014, 1:10:42 PM10/7/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:

(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Ready for checkin => Accepted


Comment:

Loic's
[https://github.com/django/django/commit/2f65b8e14c03a6b43c11d5de791b8d4d91721777#commitcomment-5799847
comment on the commit] also hasn't been addressed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:13>

Django

unread,
Oct 30, 2014, 9:12:49 AM10/30/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* cc: aaugustin (added)


Comment:

Aymeric, any thoughts here?

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:14>

Django

unread,
Nov 17, 2014, 6:55:42 PM11/17/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by gregplaysguitar):

Loic said

> Should this message be a little more explicit about what's necessary to
fix this deprecation warning?
> Usually this kind of message implies that if you manually do what the
future version of Django will
> do automatically, then you'll get rid of the deprecation warning, but
obviously setting app_label to
> None has no effect.

My point is that ther isn't anything that can be done to fix this
deprecation warning, so personally I think the
original patch – which removes it – does address Loic's concerns, and
should be fast-tracked
into a release.

At the moment I'm just ignoring all warnings because most of them are
related to this (and hence can't be fixed.)

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:15>

Django

unread,
Nov 19, 2014, 4:58:57 PM11/19/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by carljm):

Even though there is a behavior change here (from setting `app_label` to
something probably-bogus, to setting it to `None`), it is a change that
quite likely won't affect anybody. And I don't think we should raise
pending-deprecation warnings that don't have a straightforward update path
to get rid of them.

I would say this is like any other minor backwards-incompatible change to
a semi-internal detail (which is arguably a bugfix anyway, as the
currently-set value is bogus): we should just do it (that is, leave
`app_label` as `None` for abstract models that aren't in an installed app
and don't have it set explicitly), note it in the release notes, and be
done.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:16>

Django

unread,
Nov 19, 2014, 5:18:57 PM11/19/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Yes, let's just remove the warning for abstract models and hope that
doesn't break too much code when we release 1.9.

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:17>

Django

unread,
Nov 19, 2014, 5:56:19 PM11/19/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Database layer | Resolution: fixed

(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Carl Meyer <carl@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"e7b9a58b081299b30f807d5c66f7a5d1940efe4c"]:
{{{
#!CommitTicketReference repository=""
revision="e7b9a58b081299b30f807d5c66f7a5d1940efe4c"
Fixed #21794 -- Removed deprecation warning for abstract models outside an
app.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:18>

Django

unread,
Nov 19, 2014, 5:57:18 PM11/19/14
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: app-loading | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Carl Meyer <carl@…>):

In [changeset:"ac359dc7710ed8c62b6f058fe5a0ecfd6ce27602"]:
{{{
#!CommitTicketReference repository=""
revision="ac359dc7710ed8c62b6f058fe5a0ecfd6ce27602"
[1.7.x] Fixed #21794 -- Removed deprecation warning for abstract models
outside an app.

Backport of e7b9a58b081299b30f807d5c66f7a5d1940efe4c from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:19>

Django

unread,
Feb 10, 2015, 4:02:04 PM2/10/15
to django-...@googlegroups.com
#21794: No warning should be raised when defining an abstract model with no
app_label
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: app-loading | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"1b8af4cfa023161924a45fb572399d2f3071bf5b"]:
{{{
#!CommitTicketReference repository=""
revision="1b8af4cfa023161924a45fb572399d2f3071bf5b"
Disallowed importing concrete models without an application.

Removed fragile algorithm to find which application a model belongs to.

Fixed #21680, #21719. Refs #21794.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21794#comment:20>

Reply all
Reply to author
Forward
0 new messages