Skip to content

Commit

Permalink
fix: return None in get_url if instance has no pk
Browse files Browse the repository at this point in the history
  • Loading branch information
danipran committed May 3, 2024
1 parent cafcf52 commit 32774cf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions democracy/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Meta:
fields = ["title", "url", "caption"]

def get_url(self, obj):
if not obj.pk:
return None
url = reverse("serve_file", kwargs={"filetype": self.filetype, "pk": obj.pk})
if not self.context:
raise NotImplementedError("Not implemented") # pragma: no cover
Expand Down

0 comments on commit 32774cf

Please sign in to comment.