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 7, 2024
1 parent e7117b8 commit 54f468d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions democracy/views/base.py
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 54f468d

Please sign in to comment.