Skip to content

Commit

Permalink
[BUGFIX] Rule: Check content_object before accessing it #470
Browse files Browse the repository at this point in the history
models.py: Rule: Check content_object before accessing it
  • Loading branch information
kfdm committed Jan 11, 2024
2 parents d0e5148 + 88efde3 commit 814e804
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion promgen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ class Meta:
ordering = ["content_type", "object_id", "name"]

def __str__(self):
return f"{self.name} [{self.content_object.name}]"
return (
f"{self.name}"
if self.content_object is None
else f"{self.name} [{self.content_object.name}]"
)

def get_absolute_url(self):
return reverse("rule-detail", kwargs={"pk": self.pk})
Expand Down

0 comments on commit 814e804

Please sign in to comment.