Skip to content

Commit 4f18cde

Browse files
committed
add new django signals code example
1 parent e25a6d4 commit 4f18cde

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

content/pages/examples/django/django-dispatch-dispatcher-signal.markdown

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,35 @@ It is open source under the
5252
)
5353
```
5454

55+
56+
## Example 2 from aldryn-accounts
57+
[aldryn-accounts](https://github.com/divio/aldryn-accounts) is a code library
58+
for user registration and authentication in [Django](/django.html) projects.
59+
The code for this project is open source under the
60+
[MIT license](https://github.com/divio/aldryn-accounts/blob/develop/LICENSE).
61+
62+
[**aldryn-accounts/aldryn_accounts/signal.py**](https://github.com/divio/aldryn-accounts/blob/develop/aldryn_accounts/signals.py)
63+
64+
```python
65+
# -*- coding: utf-8 -*-
66+
~~import django.dispatch
67+
from django.contrib.auth import user_logged_in
68+
from django.db.models import signals, ObjectDoesNotExist
69+
from django.utils.encoding import force_text
70+
from django.utils import timezone
71+
from django.contrib.auth.models import User
72+
73+
from .utils import generate_username
74+
75+
76+
~~user_signed_up = django.dispatch.Signal(providing_args=["user", "form"])
77+
~~user_sign_up_attempt = django.dispatch.Signal(providing_args=["username", "email", "result"])
78+
~~signup_code_sent = django.dispatch.Signal(providing_args=["signup_code"])
79+
~~signup_code_used = django.dispatch.Signal(providing_args=["signup_code_result"])
80+
~~email_confirmed = django.dispatch.Signal(providing_args=["email_address"])
81+
~~email_confirmation_sent = django.dispatch.Signal(providing_args=["confirmation"])
82+
~~password_changed = django.dispatch.Signal(providing_args=["user"])
83+
84+
85+
# code continues from here without any further django.dispatch.Signal references
86+
```

0 commit comments

Comments
 (0)