Skip to content

Instantly share code, notes, and snippets.

@ojii
Created September 17, 2010 21:02
Show Gist options
  • Save ojii/584951 to your computer and use it in GitHub Desktop.
Save ojii/584951 to your computer and use it in GitHub Desktop.
from django.utils import importlib
def lazy_listen(signal, reciever, sender=None):
if sender and isinstance(sender, basestring):
module, obj = sender.rsplit('.', 1)
mod = importlib.import_module(module)
sender = getattr(mod, obj)
signal.connect(reciever, sender=sender)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment