1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Checked more precisely whether the app registry is ready.

Accounted for the three stages of population: app configs, models,
ready() methods of app configs.
This commit is contained in:
Aymeric Augustin
2014-07-12 15:33:21 +02:00
parent b48c2c5925
commit a764a9ccff
3 changed files with 48 additions and 28 deletions

View File

@@ -301,10 +301,6 @@ Application registry
Checks whether an application with the given name exists in the registry.
``app_name`` is the full name of the app, e.g. ``'django.contrib.admin'``.
Unlike :meth:`~django.apps.apps.get_app_config`, this method can be called
safely at import time. If the registry is still being populated, it may
return ``False``, even though the app will become available later.
.. method:: apps.get_model(app_label, model_name)
Returns the :class:`~django.db.models.Model` with the given ``app_label``
@@ -365,6 +361,9 @@ processes all applications in the order of :setting:`INSTALLED_APPS`.
the order of :setting:`INSTALLED_APPS`, it's strongly recommended not
import any models at this stage.
Once this stage completes, APIs that operate of application configurations
such as :meth:`~apps.get_app_config()` become usable.
#. Then Django attempts to import the ``models`` submodule of each application,
if there is one.
@@ -372,6 +371,9 @@ processes all applications in the order of :setting:`INSTALLED_APPS`.
``models/__init__.py``. Otherwise, the application registry may not be fully
populated at this point, which could cause the ORM to malfunction.
Once this stage completes, APIs that operate on models such as
:meth:`~apps.get_model()` become usable.
#. Finally Django runs the :meth:`~AppConfig.ready()` method of each application
configuration.