Best way to add existing permission to a group in Django
I'm trying to add existing permissions (from auth_permission table) to an existing group (from auth_group) in Django.
In Django shell I could do this by the following code:
from django.contrib.auth.models import Group, Permission
my_group = Group.objects.get(name='mygroupname')
perm_change = Permission.objects.get(codename='change_specific')
my_group.permissions.add(perm_change)
The code above is working as expected, but how can I make it permanent? Should I modify the model or make a custom migration?
I think that migration should work fine, but I can't figure out how to do it. (There is a way to turn my shell modifications in a migration?)
Thanks.