summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRoxane <roxane.bellot@gmail.com>2021-10-02 15:46:04 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-11-17 09:55:51 +0100
commit2d124f6a1c45afdde8be90c01043e0b14455d41e (patch)
tree698cc6eb83c8369060ebedb04281da1156ba65c2 /docs
parentbb223c6f78afb94f4305fca945f54b8603bb0105 (diff)
Fixed #33163 -- Added example of connection signal handlers in AppConfig.ready() to docs.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/signals.txt18
1 files changed, 15 insertions, 3 deletions
diff --git a/docs/topics/signals.txt b/docs/topics/signals.txt
index f4c6290a14..3e5c09b63a 100644
--- a/docs/topics/signals.txt
+++ b/docs/topics/signals.txt
@@ -136,9 +136,21 @@ Now, our ``my_callback`` function will be called each time a request finishes.
In practice, signal handlers are usually defined in a ``signals``
submodule of the application they relate to. Signal receivers are
connected in the :meth:`~django.apps.AppConfig.ready` method of your
- application configuration class. If you're using the :func:`receiver`
- decorator, import the ``signals`` submodule inside
- :meth:`~django.apps.AppConfig.ready`.
+ application :ref:`configuration class <configuring-applications-ref>`. If
+ you're using the :func:`receiver` decorator, import the ``signals``
+ submodule inside :meth:`~django.apps.AppConfig.ready`, this will implicitly
+ connect signal handlers::
+
+ from django.apps import AppConfig
+
+ class MyAppConfig(AppConfig):
+ ...
+
+ def ready(self):
+ # Implicitly connect a signal handlers decorated with @receiver.
+ from . import signals
+ # Explicitly connect a signal handler.
+ signals.request_finished.connect(signals.my_callback)
.. note::