diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-28 14:55:54 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-28 20:53:00 +0100 |
| commit | ba7206cd81458865bace85914905392291b05829 (patch) | |
| tree | f08d8ee4e1111e71bfd13a824fa35ac8cc2ba791 /docs | |
| parent | 54790e669d73269bea6320c947ed8a46e98b8025 (diff) | |
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.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/applications.txt | 4 | ||||
| -rw-r--r-- | docs/releases/1.7.txt | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt index 8f868f751e..1fc74f6bee 100644 --- a/docs/ref/applications.txt +++ b/docs/ref/applications.txt @@ -202,5 +202,5 @@ Application registry .. method:: apps.get_model(app_label, model_name) Returns the :class:`~django.db.models.Model` with the given ``app_label`` - and ``model_name``. Returns ``None`` if no such application or model - exists. ``model_name`` is case-insensitive. + and ``model_name``. Raises :exc:`~exceptions.LookupError` if no such + application or model exists. ``model_name`` is case-insensitive. diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index dbbdcf9c81..2c1b2bf26f 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -602,9 +602,15 @@ in addition to application modules, you should review code that accesses this setting directly and use the app registry (:attr:`django.apps.apps`) instead. The "app registry" that manages the list of installed applications doesn't -have the same features as the old "app cache". However, even though the "app -cache" was a private API, most of its methods were temporarily preserved and -will go through a deprecation path. +have the same features as the old "app cache". Even though the "app cache" was +a private API, obsolete methods will be removed after a standard deprecation +period. In addition, the following changes take effect immediately: + +* ``get_model`` raises :exc:`~exceptions.LookupError` instead of returning + ``None`` when no model is found. + +* The ``only_installed`` and ``seed_cache`` arguments of ``get_model`` no + longer exist. While the new implementation is believed to be more robust, regressions cannot be ruled out, especially during the import sequence. Circular imports that |
