Changed get_model to raise an exception on errors.

Returning None on errors required unpythonic error checking and was
inconsistent with get_app_config.

get_model was a private API until the previous commit, but given that it
was certainly used in third party software, the change is explained in
the release notes.

Applied the same change to get_registered_model, which is a new private
API introduced during the recent refactoring.
This commit is contained in:
Aymeric Augustin 2013-12-28 14:55:54 +01:00
parent 54790e669d
commit ba7206cd81
20 changed files with 80 additions and 53 deletions

View file

@ -72,8 +72,8 @@ class GetModelsTest(TestCase):
self.not_installed_module = models
def test_get_model_only_returns_installed_models(self):
self.assertEqual(
apps.get_model("not_installed", "NotInstalledModel"), None)
with self.assertRaises(LookupError):
apps.get_model("not_installed", "NotInstalledModel")
def test_get_models_only_returns_installed_models(self):
self.assertNotIn(