From b62f72498af8a8cb4ddb3000421c5642bda57761 Mon Sep 17 00:00:00 2001
From: Loic Bistuer <loic.bistuer@gmail.com>
Date: Thu, 23 Oct 2014 01:28:57 +0700
Subject: [PATCH] Improved warning message when reloading models. Refs #23621.

Thanks dfunckt and Tim Graham.
---
 django/apps/registry.py | 4 +++-
 tests/apps/tests.py     | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/django/apps/registry.py b/django/apps/registry.py
index 55116e2809..fe53d965de 100644
--- a/django/apps/registry.py
+++ b/django/apps/registry.py
@@ -211,7 +211,9 @@ class Apps(object):
             if (model.__name__ == app_models[model_name].__name__ and
                     model.__module__ == app_models[model_name].__module__):
                 warnings.warn(
-                    "Model '%s.%s' was already registered." % (model_name, app_label),
+                    "Model '%s.%s' was already registered. "
+                    "Reloading models is not advised as it can lead to inconsistencies, "
+                    "most notably with related models." % (model_name, app_label),
                     RuntimeWarning, stacklevel=2)
             else:
                 raise RuntimeError(
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index 7246cd57d6..1a308efb6a 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -234,7 +234,10 @@ class AppsTests(TestCase):
             type(str("SouthPonies"), (models.Model,), body)
             self.assertEqual(len(w), 1)
             self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
-            self.assertEqual(str(w[-1].message), "Model 'southponies.apps' was already registered.")
+            self.assertEqual(str(w[-1].message),
+                 "Model 'southponies.apps' was already registered. "
+                 "Reloading models is not advised as it can lead to inconsistencies, "
+                 "most notably with related models.")
 
         # If it doesn't appear to be a reloaded module then we expect
         # a RuntimeError.