1. Kai Diefenbach
  2. django_permissions
Issue #2 resolved

Role's get_roles doesn't work

Jakub Wiśniowski
created an issue

The following code:

{{{

!python

role = Roles.objects.get(id=1) role.get_groups() }}}

doesn't work. There is a problem with "content" parameter which is used in get_groups (line 124 in models.py):

{{{

!python

return PrincipalRoleRelation.objects.filter(role=self, content=content) }}}

The problem is that this is a generic relation so filter can't be used this way. My quick fix is below:

{{{

!python

if content is not None: content_type = ContentType.objects.get_for_model(content) return PrincipalRoleRelation.objects.filter(role=self.pk, content_type=content_type, content_id=content.id) return PrincipalRoleRelation.objects.filter(role=self.pk)

}}}

Comments (4)

  1. Log in to comment