Skip to content

Commit 4ad369f

Browse files
committed
Correct preview logic for unpublished pages
1 parent 9187549 commit 4ad369f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pages/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ def get_content(self):
224224
def get_context(self, request, *args, **kwargs):
225225
ctx = super().get_context(request, *args, **kwargs)
226226
pages = self.__class__.objects.live().order_by("-first_published_at")
227-
next_objects = pages.filter(first_published_at__gt=self.first_published_at)
227+
if self.live:
228+
next_objects = pages.filter(first_published_at__gt=self.first_published_at)
229+
else:
230+
next_objects = pages
228231
ctx["next_post_items"] = [next_objects.last()]
229232
ctx["related_posts"] = pages.filter(content__0__type=self.stream_content_type)[
230233
:3

0 commit comments

Comments
 (0)