from django db models import signals from accounts models import User

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from django.db.models import signals
from accounts.models import User
from repo.models import Repo
from social.event_source import EventSource
def new_entity_event_source(sender, instance, **kwargs):
try:
instance.event_source
except EventSource.DoesNotExist:
instance.event_source = EventSource()
instance.event_source.save()
signals.post_init.connect(new_entity_event_source, sender=User)
signals.post_init.connect(new_entity_event_source, sender=Repo)