Skip to content

Commit

Permalink
Minimize try block to code that we expect to potetially raise ValueError
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Miller <dmiller@dimagi.com>
  • Loading branch information
gherceg and millerdev committed Nov 20, 2023
1 parent 9c0f277 commit d375bbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_prbac/models.py
Expand Up @@ -145,11 +145,11 @@ def get_privileges(self, assignment):
except AttributeError:
pass
try:
return [membership.instantiated_to_role(assignment)
for membership in self.memberships_granted.all()]
memberships = self.memberships_granted.all()
except ValueError:
# Django 4 raises ValueError if fk relationship is accessed prior to save
return []
return [m.instantiated_to_role(assignment) for m in memberships]

def instantiate(self, assignment):
"""
Expand Down

0 comments on commit d375bbe

Please sign in to comment.