From 0d7aa2390d90ca969a8daf8ee1b2fc716400867d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Apr 2012 00:03:10 +0200 Subject: [PATCH] added queryviews --- manifests/ships/queryviews.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 manifests/ships/queryviews.py diff --git a/manifests/ships/queryviews.py b/manifests/ships/queryviews.py new file mode 100644 index 0000000..0a8f15b --- /dev/null +++ b/manifests/ships/queryviews.py @@ -0,0 +1,12 @@ +from models import * +from django.shortcuts import render_to_response +from django.http import HttpResponse + +def uniqueShips(request): + ships = Ship.objects.values('ship_name', 'ship_name_trans').distinct('ship_name') + return render_to_response("uniqueShips.html", {'ships': ships, 'count': ships.count()}) + + +def uniquePorts(request): + ports = Ship.objects.order_by('port').values('port').distinct() + return render_to_response("uniquePorts.html", {'ports': ports, 'count': ports.count()})