immitating 'real' post_syncdb signal

1
2
3
4
5
6
7
8
9
# This code must live in management.py in one of the applications in your INSTALLED_APPS
from django.db.models.signals import post_syncdb
import diacre.settings as settings
def load_data(sender, **kwargs):
    if kwargs['app'].__name__ == settings.INSTALLED_APPS[-1] + ".models":
        pass
        # load fixtures here

post_syncdb.connect(load_data)

More like this

  1. post_migrate handler to load initial SQL after migrating with south by stingydrone 2 years, 4 months ago
  2. easy signal registration by aisbaa 1 year, 7 months ago
  3. REMOVE IMAGEFIELD ATTACHMENT IN DJANGO by timonweb 1 year ago
  4. Alter Column Lengths of Contrib Apps by guettli 5 years, 1 month ago
  5. Create permissions for proxy models by charettes 1 year, 3 months ago

Comments

pakalk (on April 17, 2010):
  1. Why is it 'real' signal?
  2. What is the problem with using settings.INSTALLED_APPS[-1] instead of settings.INSTALLED_APPS[last_index - 1]?
  3. Does last_index really keep last index?

#

jango (on April 18, 2010):
  1. I called it "real" because when I was looking for something like that, a bunch of people on the form keep calling this functionality a "real post_syncdb" signal because code fires after syncdb is more or less over, as opposed to when individual model is installed.

2, 3. - you are right, that wasn't too pythonish, thanks.

#

(Forgotten your password?)