Also filter entries by expire_at in the news section of the home page

This commit is contained in:
PCoder 2022-05-04 10:28:34 +05:30
parent 2d287dff32
commit 7d11a440c6
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,8 @@
from __future__ import unicode_literals
import datetime
from django.db import models
from django.utils import translation
from django.conf import settings
@ -320,7 +322,9 @@ class HomePage(Page):
@property
def newsentries(self):
# Get the last few news entries for the home page
entries = Entry.objects.all().order_by('-published')
entries = Entry.objects.filter(
models.Q(expire_at__isnull=True) | models.Q(expire_at__gt=datetime.datetime.now())
).all().order_by('-published')
# Filter out by current language
curlang = translation.get_language()
if curlang in ['de']: