Commit 2f65b8e1 authored by Aymeric Augustin's avatar Aymeric Augustin
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.
parent 8a34d356
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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('.')