Hook to perform actions after loaddata command (loading fixtures)
Question: There's `post_syncdb` signal to perform actions that can be done after syncdb.
Is there a similar hook to perform some actions after loading fixtures i.e.
after `python manage.py loaddata` command ?

I have a script that creates a new database, runs migrate (syncdb) and loads
data from JSON fixtures. Post all this, I want to create groups & permissions
for users that have been created. Where do I plug that code?

P.S. Use `post_migrate` instead of `post_syncdb` for 1.7+


Answer: [Read the source, Luke](http://blog.codinghorror.com/learn-to-read-the-source-
luke/).

Research how `post_migrate` (or `post_syncdb`) signal is fired in the
management command, see:

  * [`emit_post_migrate_signal()`](https://github.com/django/django/blob/master/django/core/management/commands/migrate.py#L197) call at the end of the `handle()` method
  * how [`emit_post_migrate_signal()`](https://github.com/django/django/blob/master/django/core/management/sql.py#L265-285) is responsible for sending `models.signals.post_migrate` signal 

From what we've seen, here is what you should try:

  * [create a custom signal](https://docs.djangoproject.com/en/dev/topics/signals/#defining-and-sending-signals) (and listener where you would create groups & permissions)
  * [create a custom management command](https://docs.djangoproject.com/en/dev/howto/custom-management-commands/) subclassing `loaddata` `Command` and overriding `handle()` method:
    
        from django.core.management.commands.loaddata import Command
    
    class MyCommand(Command):
        def handle(self, *fixture_labels, **options):
            super(MyCommand, self).handle(*fixture_labels, **options)
    
            my_signal.send(sender=self.__class__, my_argument=my_argument_value)
    

Haven't personally tested this. Hope it works for you.

