Search code examples
pythondjangosignalsdjango-syncdb

Django post_syncdb signal handler not getting called?


I have a myapp/management/__init__.py that is registering a post_syncdb handler like so:

from django.db.models import signals
from features import models as features

def create_features(app, created_models, verbosity, **kwargs):
    print "Creating features!"
    # Do stuff...

signals.post_syncdb.connect(create_features, sender=features)

I've verified the following:

  1. Both features and myapp are in settings.INSTALLED_APPS
  2. myapp.management is getting loaded prior to the syncdb running (verified via a print statement at the module level)
  3. The features app is getting processed by syncdb, and it is emitting a post_syncdb signal (verified by examining syncdb's output with --verbosity=2.
  4. I'm using the exact same idiom for another pair of apps, and that handler is called correctly. I've compared the two modules and found no relevant differences between the invocations.

However, myapp.management.create_features is never called. What am I missing?


Solution

  • try putting it in your models.py