Search code examples
djangodjango-signals

Django: Signal for "post initial migration"


For setting up new development systems I would like to have a "post initial migration" signal.

It seems that something like this does not exist yet.

In detail: I want a signal which runs after the initial migrations have run. The second call to "manage.py migrate" should not emit this signal.

Use case: I want to set up basic data (add some users and groups, add some dummy data for "example.com", ...).

I don't want to use a migration for this, since in a migration I have only the limited model which gets returned by apps.get_model("myapp", "Country").

Same for fixtures: I don't want to use fixtures because I get my tasks done much less painful if I have the real ORM model.

Is there a way to work around it?


Solution

  • You could use the post_migrate signal. Check to see whether your dummy data has already been created (e.g. if User.objects.exists():) and stop if it does.