Answer the question
In order to leave comments, you need to log in
Why aren't groups populated automatically after a Django migration?
The task is to automatically create groups after starting the project and add the list of permissions.
The implementation is the post_migrate signal. That is, after each migration, create groups and a list of permissions
Questions:
1) Why does this code work:
@receiver(post_migrate)
def populate_models(sender, **kwargs):
print('Populating groups....')
....
@receiver(post_migrate, sender=apps.BoardConfig)
def populate_models(sender, **kwargs):
print('Populating groups....')
....
and isolate signals in a separate file Answer the question
In order to leave comments, you need to log in
The sender is the config object and not the config class. And the optimal implementation is highly dependent on the context.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question