From 2f65b8e14c03a6b43c11d5de791b8d4d91721777 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 18 Jan 2014 18:22:11 +0100 Subject: [PATCH] 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. --- django/db/models/base.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index d7b54b9268..141d28eb7f 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -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('.')