suhail areekkan suhail areekkan - 1 year ago 164
Python Question

Django signals not receiving/working

i am using django default receiver to handle signal. but its not working.
i have modified User model in APP1 whenver new User object create a receiver in APP2 is listen to it, but its not working.


class User(BaseModel, AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
verbose_name='email address',
username = models.CharField(max_length=40, unique=True)
first_name = models.CharField(max_length=30, blank=True, null=True)
last_name = models.CharField(max_length=30, blank=True, null=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
is_email_verified = models.BooleanField(default=False)
is_paid = models.IntegerField(default=0)
access_token = models.CharField(max_length=128, blank=True)

objects = UserManager()

REQUIRED_FIELDS = ['username']

class Meta:
db_table = 'users'

def __str__(self):


from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from accounts.models import User

@receiver(post_save, sender=User)#settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
print ("token generated")
if created:
print("data at signal ****",, instance)

Answer Source

finaly i got the answer . its because i'm not importing on startup.

working code

from __future__ import unicode_literals

from django.apps import AppConfig

    class StreamsConfig(AppConfig):
        name = 'streams'    

        def ready(self):
            print("at ready")
            import streams.signals

default_app_config = 'streams.apps.StreamsConfig'

after this change i'm receiving signals

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download