From 6c148370e70023dbc2478b321365f8e62d9bc07c Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 22 Apr 2012 16:47:40 +0530 Subject: [PATCH] make dates work --- manifests/ships/views.py | 9 ++++++++- manifests/templates/shipList.html | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/manifests/ships/views.py b/manifests/ships/views.py index afa0e51..3192cfb 100644 --- a/manifests/ships/views.py +++ b/manifests/ships/views.py @@ -10,6 +10,7 @@ from ox.django.shortcuts import render_to_json_response from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator, InvalidPage, EmptyPage +from datetime import datetime #import pdb @login_required @@ -180,7 +181,13 @@ def shipList(request): goods = request.GET.get('goods', '') # country = request.GET.get('country', None) qset = Ship.objects.all() - #add dates stuff + if startDate != '': + start_dt = datetime.strptime(startDate, '%Y-%m-%d') + qset = qset.filter(date__gte=start_dt) + if endDate != '': + end_dt = datetime.strptime(endDate, '%Y-%m-%d') + qset = qset.filter(date__lte=end_dt) + if billType != '': qset = qset.filter(bill_type__iexact=billType) if shipName != '': diff --git a/manifests/templates/shipList.html b/manifests/templates/shipList.html index 552b2f7..a8032f7 100644 --- a/manifests/templates/shipList.html +++ b/manifests/templates/shipList.html @@ -27,10 +27,13 @@ No of results: {{ no_of_results }}   displaying page {{ page }} of {{ no_of
- + + +
+ + +
+