Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 2f65b8e14c03a6b43c11d5de791b8d4d91721777 1 parent 8a34d35
@aaugustin aaugustin authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 django/db/models/base.py
View
14 django/db/models/base.py
@@ -104,12 +104,16 @@ def __new__(cls, name, bases, attrs):
# For 'django.contrib.sites.models', this would be 'sites'.
# For 'geo.models.places' this would be 'geo'.
- warnings.warn(
+ msg = (
"Model class %s.%s doesn't declare an explicit app_label "
- "and either isn't in an application in INSTALLED_APPS "
- "or else was imported before its application was loaded. "
- "This will no longer be supported in Django 1.9."
- % (module, name), PendingDeprecationWarning, stacklevel=2)
+ "and either isn't in an application in INSTALLED_APPS or "
+ "else was imported before its application was loaded. " %
+ (module, name))
+ if abstract:
+ msg += "Its app_label will be set to None in Django 1.9."
@loic Collaborator
loic added a note

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.

Or maybe we should just skip the warning and assign an app_label of None if there is no explicit app_label. Personally I use explicit app_label on abstract classes, to group them when graphing my models with graphviz, but I don't think Django ever use them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ else:
+ msg += "This will no longer be supported in Django 1.9."
+ warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
model_module = sys.modules[new_class.__module__]
package_components = model_module.__name__.split('.')
@loic

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.

Or maybe we should just skip the warning and assign an app_label of None if there is no explicit app_label. Personally I use explicit app_label on abstract classes, to group them when graphing my models with graphviz, but I don't think Django ever use them.

Please sign in to comment.
Something went wrong with that request. Please try again.