{"action":"closed","issue":{"url":"https://api.github.com/repos/django-guardian/django-guardian/issues/155","labels_url":"https://api.github.com/repos/django-guardian/django-guardian/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/django-guardian/django-guardian/issues/155/comments","events_url":"https://api.github.com/repos/django-guardian/django-guardian/issues/155/events","html_url":"https://github.com/django-guardian/django-guardian/issues/155","id":17106170,"number":155,"title":"Differentiate between Django's default model permissions and custom permissions","user":{"login":"whitews","id":1298022,"avatar_url":"https://avatars.githubusercontent.com/u/1298022?v=3","gravatar_id":"","url":"https://api.github.com/users/whitews","html_url":"https://github.com/whitews","followers_url":"https://api.github.com/users/whitews/followers","following_url":"https://api.github.com/users/whitews/following{/other_user}","gists_url":"https://api.github.com/users/whitews/gists{/gist_id}","starred_url":"https://api.github.com/users/whitews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitews/subscriptions","organizations_url":"https://api.github.com/users/whitews/orgs","repos_url":"https://api.github.com/users/whitews/repos","events_url":"https://api.github.com/users/whitews/events{/privacy}","received_events_url":"https://api.github.com/users/whitews/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/django-guardian/django-guardian/labels/API%20change","name":"API change","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2013-07-23T15:07:06Z","updated_at":"2015-12-22T10:41:44Z","closed_at":"2015-12-22T10:41:44Z","body":"Hi,\r\n\r\nI believe this came up before in issue #42 and I think it would be useful to have a mechanism to exclude the default permissions in `BaseObjectPermissionsForm`.\r\n\r\nUnfortunately, as you've indicated in the responses to that issue, there is no real distinction between the Permission instances. I am currently doing this by creating my own Form and overriding `get_obj_perms_field_choices()` to filter the permissions using  Model._meta like so:\r\n\r\n    class UserProjectPermissionForm(UserObjectPermissionsForm):\r\n        def get_obj_perms_field_choices(self):\r\n            choices = super(UserProjectPermissionForm, self).get_obj_perms_field_choices()\r\n            return list(set(choices).intersection(Project._meta.permissions))\r\n\r\nOf course, I'd like to avoid using a private attribute, but as far as I can tell using `_meta` is the only way to access the custom permissions. I realize it's just shifting to problem over to guardian, but what about adding an optional init argument to `BaseObjectPermissionsForm` to set a property like \"exclude_default\" and then use it in `get_obj_perms_field_choices()` to filter these permissions using something similar:\r\n\r\n    def get_obj_perms_field_choices(self):\r\n            \"\"\"\r\n            Returns choices for object permissions management field. Default:\r\n            list of tuples ``(codename, name)`` for each ``Permission`` instance\r\n            for the managed object.\r\n            \"\"\"\r\n            choices = [(p.codename, p.name) for p in get_perms_for_model(self.obj)]\r\n        \r\n            if self.exclude_default:\r\n                choices = list(set(choices).intersection(self.obj._meta.permissions))\r\n\r\n            return choices\r\n\r\nDoes this sound reasonable, or would there be a better way to implement it?\r\n\r\nThanks!"}}