mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	[4.0.x] Fixed #33163 -- Added example of connection signal handlers in AppConfig.ready() to docs.
Backport of 2d124f6a1c from main
			
			
This commit is contained in:
		
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -816,6 +816,7 @@ answer newbie questions, and generally made Django that much better: | |||||||
|     Romain Garrigues <romain.garrigues.cs@gmail.com> |     Romain Garrigues <romain.garrigues.cs@gmail.com> | ||||||
|     Ronny Haryanto <https://ronny.haryan.to/> |     Ronny Haryanto <https://ronny.haryan.to/> | ||||||
|     Ross Poulton <ross@rossp.org> |     Ross Poulton <ross@rossp.org> | ||||||
|  |     Roxane Bellot <https://github.com/roxanebellot/> | ||||||
|     Rozza <ross.lawley@gmail.com> |     Rozza <ross.lawley@gmail.com> | ||||||
|     Rudolph Froger <rfroger@estrate.nl> |     Rudolph Froger <rfroger@estrate.nl> | ||||||
|     Rudy Mutter |     Rudy Mutter | ||||||
|   | |||||||
| @@ -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`` |     In practice, signal handlers are usually defined in a ``signals`` | ||||||
|     submodule of the application they relate to. Signal receivers are |     submodule of the application they relate to. Signal receivers are | ||||||
|     connected in the :meth:`~django.apps.AppConfig.ready` method of your |     connected in the :meth:`~django.apps.AppConfig.ready` method of your | ||||||
|     application configuration class. If you're using the :func:`receiver` |     application :ref:`configuration class <configuring-applications-ref>`. If | ||||||
|     decorator, import the ``signals`` submodule inside |     you're using the :func:`receiver` decorator, import the ``signals`` | ||||||
|     :meth:`~django.apps.AppConfig.ready`. |     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:: | .. note:: | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user