diff options
Diffstat (limited to 'app/posts/views/jrnl_views.py')
-rw-r--r-- | app/posts/views/jrnl_views.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/posts/views/jrnl_views.py b/app/posts/views/jrnl_views.py index bfc0a42..6692b0f 100644 --- a/app/posts/views/jrnl_views.py +++ b/app/posts/views/jrnl_views.py @@ -1,3 +1,4 @@ +import datetime from django.views.generic import ListView from django.views.generic.detail import DetailView from django.views.generic.dates import DateDetailView @@ -103,10 +104,14 @@ class JrnlDetailView(DateDetailView): def get_context_data(self, **kwargs): context = super(JrnlDetailView, self).get_context_data(**kwargs) + timeago = self.object.pub_date - datetime.timedelta(days=45) + timepadding = self.object.pub_date + datetime.timedelta(days=30) context['wildlife'] = Sighting.objects.filter( Q(location=self.location) | Q(location__in=Location.objects.filter(parent=self.location)) - ).select_related().order_by('ap_id', 'ap__apclass__kind').distinct("ap") + ).filter( + pub_date__range=(timeago,timepadding) + ).order_by('ap_id', 'ap__apclass__kind').distinct("ap") related = [] for obj in self.object.related.all(): model = apps.get_model(obj.model_name.app_label, obj.model_name.model) |