django - Hook to perform actions after loaddata command (loading fixtures) -



django - Hook to perform actions after loaddata command (loading fixtures) -

there's post_syncdb signal perform actions can done after syncdb. there similar hook perform actions after loading fixtures i.e. after python manage.py loaddata command ?

i have script creates new database, runs migrate (syncdb) , loads info json fixtures. post this, want create groups & permissions users have been created. plug code?

p.s. utilize post_migrate instead of post_syncdb 1.7+

read source, luke.

research how post_migrate (or post_syncdb) signal fired in management command, see:

emit_post_migrate_signal() phone call @ end of handle() method how emit_post_migrate_signal() responsible sending models.signals.post_migrate signal

from we've seen, here should try:

create custom signal (and listener create groups & permissions)

create custom management command subclassing loaddata command , 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 tested this. hope works you.

django django-fixtures django-migrations

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -