Clone wiki

django-authority / Home

Adding permissions in python code

The first test case of contributed tests demonstrate how to add permissions manually.


Currently, assigning permissions to users work, but not to groups.

Check tests for the implementation. Note that test_all() doesn't pass. This means that you should always pass a value to the check argument of assign().


Returns a codename in format: appname.permissionname_modelname Example: auth.add_user

Authority permission codename

Returns a codename in format: permissionlabel.permissionname_modelname Example: yourmodel.browse_somemodel

Example usage

permission.assign(content_object=somemodel, check=somecheck)
permission.assign(content_object=(somemodel, someothermodel), check=(somecheck, someothercheck))