django rest DjangoModelPermissions include get 1

django rest DjangoModelPermissions include get

class CustomDjangoModelPermission(permissions.DjangoModelPermissions):

    def __init__(self):
        self.perms_map = copy.deepcopy(self.perms_map)  # from EunChong's answer
        self.perms_map['GET'] = ['%(app_label)s.view_%(model_name)s']

Here is what the above code is Doing:
1. It’s copying the perms_map dictionary from the parent class.
2. It’s changing the value of the ‘GET’ key to be a list containing a single string.
3. It’s passing that dictionary to the parent class’s __init__ method.

Similar Posts