Created
June 26, 2013 05:37
-
-
Save venkatesh22/5865016 to your computer and use it in GitHub Desktop.
django custom signals creation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#signals.py | |
from django.dispatch import Signal | |
user_login = Signal(providing_args=["request", "user"]) | |
#views.py | |
from foo import signals | |
def login(request): | |
... | |
if request.user.is_authenticated(): | |
signals.user_login.send(sender=None, request=request, user=request.user) | |
#tasks.py | |
from foo.signals import user_login | |
def user_login_handler(sender, **kwargs): | |
"""signal intercept for user_login""" | |
user = kwargs['user'] | |
... | |
user_login.connect(user_login_handler) |
foo is a dummy name. Replace it with your own filename.
What version(s) of Django does this support?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i get an error while using foo
( could not find a version that satisfies the requirement foo )
How can i solve it ?!!!