add show tags of last months only

This commit is contained in:
2021-02-01 21:44:04 +00:00
parent 274e09579a
commit cce4d2e219
3 changed files with 10 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ from django.db import models
from django.db.models import Q
from django.utils import timezone
from datetime import timedelta
class PostManager(models.Manager):
def get_queryset(self):
@@ -10,7 +12,11 @@ class PostManager(models.Manager):
def get_visible_articles(self):
return self.get_queryset().filter(is_hidden=False)
def all_post_with_date(self):
def get_last_months_posts(self):
date_today = timezone.now().date()
return self.get_visible_articles().filter(public_date__gt=date_today - timedelta(days=365))
def get_all_posts_with_date(self):
return (
self.get_queryset()
.filter(Q(event_start__isnull=False) & Q(event_end__isnull=False))