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.
This commit is contained in:
Aymeric Augustin 2014-01-18 18:22:11 +01:00
parent 8a34d35696
commit 2f65b8e14c
1 changed files with 9 additions and 5 deletions

View File

@ -104,12 +104,16 @@ class ModelBase(type):
# 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."
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('.')