|
1 | | -title: django.dispatch.dispatcher.Signal Examples |
| 1 | +title: django.dispatch Signal Examples |
2 | 2 | category: page |
3 | 3 | slug: django-dispatch-dispatcher-signal-examples |
4 | 4 | sortorder: 50004 |
5 | 5 | toc: False |
6 | | -sidebartitle: django.dispatch.dispatcher Signal |
| 6 | +sidebartitle: django.dispatch Signal |
7 | 7 | meta: Python code examples for the Signal class within the django.dispatch module of the Django project. |
8 | 8 |
|
9 | 9 |
|
10 | | -# django.dispatch.dispatcher Signal Examples |
| 10 | +# django.dispatch Signal Examples |
11 | 11 | The |
12 | 12 | [Signal](https://github.com/django/django/blob/master/django/dispatch/dispatcher.py) |
13 | 13 | class allows certain senders to notify a set of receivers that some action |
@@ -84,3 +84,24 @@ from .utils import generate_username |
84 | 84 |
|
85 | 85 | # code continues from here without any further django.dispatch.Signal references |
86 | 86 | ``` |
| 87 | + |
| 88 | + |
| 89 | +## Example 3 from django-easy-timezones |
| 90 | +[django-easy-timezones](https://github.com/Miserlou/django-easy-timezones) |
| 91 | +([project website](https://www.gun.io/blog/django-easy-timezones)) |
| 92 | +is a [Django](/django.html) |
| 93 | +[middleware](https://docs.djangoproject.com/en/2.2/topics/http/middleware/) |
| 94 | +[code library](https://pypi.org/project/django-easy-timezones/) |
| 95 | +to simplify handling time data in your applications using |
| 96 | +users' geolocation data. |
| 97 | + |
| 98 | +[**django-easy-timezones/easy_timezones/signals.py**](https://github.com/Miserlou/django-easy-timezones/blob/master/easy_timezones/middleware.py) |
| 99 | + |
| 100 | +```python |
| 101 | +# Django |
| 102 | +~~import django.dispatch |
| 103 | + |
| 104 | +~~detected_timezone = django.dispatch.Signal(providing_args=["instance", "timezone"]) |
| 105 | +``` |
| 106 | + |
| 107 | + |
0 commit comments