Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added AppConfig.setup() to run setup code.

  • Loading branch information...
commit e187caa3afd7d292353fb32be1647da2cf0968da 1 parent 0d2c8ff
@aaugustin aaugustin authored
View
5 django/apps/base.py
@@ -162,3 +162,8 @@ def import_models(self, all_models):
if module_has_submodule(self.module, MODELS_MODULE_NAME):
models_module_name = '%s.%s' % (self.name, MODELS_MODULE_NAME)
self.models_module = import_module(models_module_name)
+
+ def setup(self):
+ """
+ Override this method in subclasses to run setup code.
+ """
View
3  django/apps/registry.py
@@ -135,6 +135,9 @@ def populate_models(self):
self.clear_cache()
self._models_loaded = True
+ for app_config in self.get_app_configs():
+ app_config.setup()
+
@property
def ready(self):
"""
View
6 docs/ref/applications.txt
@@ -166,6 +166,12 @@ Methods
``model_name``. Raises :exc:`~exceptions.LookupError` if no such model
exists. ``model_name`` is case-insensitive.
+.. method:: AppConfig.setup()
+
+ Subclasses can override this method to perform setup tasks such as
+ registering signals. It is called as soon as the registry is fully
+ populated.
+
Application registry
====================

0 comments on commit e187caa

Please sign in to comment.
Something went wrong with that request. Please try again.