Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #33163 -- Added example of connection signal handlers in AppConfig.ready() to docs. #14925

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -819,6 +819,7 @@ answer newbie questions, and generally made Django that much better:
Romain Garrigues <romain.garrigues.cs@gmail.com>
Ronny Haryanto <https://ronny.haryan.to/>
Ross Poulton <ross@rossp.org>
Roxane Bellot <https://github.com/roxanebellot/>
Rozza <ross.lawley@gmail.com>
Rudolph Froger <rfroger@estrate.nl>
Rudy Mutter
Expand Down
18 changes: 15 additions & 3 deletions docs/topics/signals.txt
Expand Up @@ -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::

Expand Down