From 82f01f5f10190bcb70cb5357ec4bac542b7c197a Mon Sep 17 00:00:00 2001 From: lxf Date: Fri, 18 Feb 2022 11:51:48 -0500 Subject: trad: fixed some bugs in list view --- app/trading/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/trading/views.py b/app/trading/views.py index 432e21d..62f0dd5 100644 --- a/app/trading/views.py +++ b/app/trading/views.py @@ -1,4 +1,4 @@ -from datetime import datetime +import datetime from django.http import HttpResponseRedirect from django.utils import timezone from django.views.generic.edit import CreateView, UpdateView @@ -25,16 +25,17 @@ class LuxTradeListView(PaginatedListView): #context['options_year_pl'] = LuxOptionsTrade.stats.get_year_pl() context['options_monthly_pl'] = LuxOptionPurchase.stats.get_month_pl() context['options_year_pl'] = LuxOptionPurchase.stats.get_year_pl() - context['month'] = datetime.now().strftime('%h') + context['month'] = timezone.now().strftime('%h') context['luxoptions_purchases'] = LuxOptionPurchase.objects.all() return context def get_queryset(self): queryset = super(LuxTradeListView, self).get_queryset() queryset = queryset.filter(status=1) - start_date = datetime.date(timezone.now().year, 1, 1) - end_date = datetime.date(timezone.now().year, 12, 31) - return self.filter(close_date__range=(start_date, end_date)) + year=timezone.now().year + start_date = datetime.date(year, 1, 1) + end_date = datetime.date(year, 12, 31) + return queryset.filter(close_date__range=(start_date, end_date)) class LuxTradeDetailView(UpdateView): -- cgit v1.2.3-70-g09d2