How I can use python in order to populate and modify groups?

I am using proxy models in order to manage Users and groups?

class User(AbstractUser):
    bio = models.TextField()

    def __str__(self):
        return self.first_name+' '+self.last_name

class Author(Group):
    class Meta:
        proxy=True
        permissions=[("create_article","User can create article"),("edit_article","Edit Article")]

class Publisher(Group):
    class Meta:
        proxy=True
        permissions=[("edit_article","Edit Article")]

Is there a way to automatically create the nessesary migration in order once I change the permissions upon code also be changed into Db as well?

My goal is somehow to have a config file with all permissions and a list that would define what permissions each groups would have. Then using this config file the django would check the user permissions.

Вернуться на верх