Loading docs/ref/signals.txt +9 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,15 @@ For example, you could register a callback in an def ready(self): post_migrate.connect(my_callback, sender=self) .. note:: If you provide an :class:`~django.apps.AppConfig` instance as the sender argument, please ensure that the signal is registered in :meth:`~django.apps.AppConfig.ready`. ``AppConfig``\s are recreated for tests that run with a modified set of :setting:`INSTALLED_APPS` (such as when settings are overridden) and such signals should be connected for each new ``AppConfig`` instance. post_syncdb ----------- Loading docs/topics/signals.txt +7 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,13 @@ Now, our ``my_callback`` function will be called each time a request finishes. versions of Django, signal registration usually happened in the ``models`` module. .. note:: The :meth:`~django.apps.AppConfig.ready` method may be executed more than once during testing, so you may want to :ref:`guard your signals from duplication <preventing-duplicate-signals>`, especially if you're planning to send them within tests. .. _connecting-to-specific-signals: Connecting to signals sent by specific senders Loading Loading
docs/ref/signals.txt +9 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,15 @@ For example, you could register a callback in an def ready(self): post_migrate.connect(my_callback, sender=self) .. note:: If you provide an :class:`~django.apps.AppConfig` instance as the sender argument, please ensure that the signal is registered in :meth:`~django.apps.AppConfig.ready`. ``AppConfig``\s are recreated for tests that run with a modified set of :setting:`INSTALLED_APPS` (such as when settings are overridden) and such signals should be connected for each new ``AppConfig`` instance. post_syncdb ----------- Loading
docs/topics/signals.txt +7 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,13 @@ Now, our ``my_callback`` function will be called each time a request finishes. versions of Django, signal registration usually happened in the ``models`` module. .. note:: The :meth:`~django.apps.AppConfig.ready` method may be executed more than once during testing, so you may want to :ref:`guard your signals from duplication <preventing-duplicate-signals>`, especially if you're planning to send them within tests. .. _connecting-to-specific-signals: Connecting to signals sent by specific senders Loading