4👍
✅
Research how post_migrate
(or post_syncdb
) signal is fired in the management command, see:
emit_post_migrate_signal()
call at the end of thehandle()
method- how
emit_post_migrate_signal()
is responsible for sendingmodels.signals.post_migrate
signal
From what we’ve seen, here is what you should try:
- create a custom signal (and listener where you would create groups & permissions)
-
create a custom management command subclassing
loaddata
Command
and overridinghandle()
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.
Source:stackexchange.com