edit BlogPost.get_absolute_url

This commit is contained in:
DELL 2022-10-07 14:07:53 +07:00
parent c44fb6c47a
commit 11e4bc5a10

View file

@ -98,13 +98,7 @@ class BlogPost(models.Model):
return self.title return self.title
def get_absolute_url(self): def get_absolute_url(self):
try: return reverse("blog_post", args=(self.id , self.slug))
BlogPost.objects.get(id=self.id)
return reverse("blog_post", args=(self.id , self.slug))
except BlogPost.DoesNotExist:
return reverse("organization_pending_blogs",
args=(self.organizations.first().pk, self.organizations.first().slug))
def can_see(self, user): def can_see(self, user):
if self.visible and self.publish_on <= timezone.now(): if self.visible and self.publish_on <= timezone.now():
if not self.is_organization_private: if not self.is_organization_private: