Skip to content

Instantly share code, notes, and snippets.

@venkatesh22
Created June 26, 2013 05:37
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save venkatesh22/5865016 to your computer and use it in GitHub Desktop.
Save venkatesh22/5865016 to your computer and use it in GitHub Desktop.
django custom signals creation example
#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)
@modysaeed
Copy link

i get an error while using foo
( could not find a version that satisfies the requirement foo )

How can i solve it ?!!!

@karatugo
Copy link

foo is a dummy name. Replace it with your own filename.

@stodge
Copy link

stodge commented Mar 16, 2018

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