In my django application, all the data of different clients are
entered. Sometimes data of even same client is also entered. Now what
I require is to get all the data of the client when it asked for.
The views I used is:
------------------------------------------------------------------------------------------------------------------------------------
def old_client(request):
if request.method == 'POST':
form = OldClientadd(request.POST)
if form.is_valid():
from TCC11_12.automation.functions import *
cd = form.cleaned_data
name_and_address = cd['name_and_address']
title = get_object_or_404(Variable, pk='1')
sign = get_object_or_404(Variable, pk='3')
from TCC11_12.automation.choices import *
client =
ClientJob.objects.filter(name_and_address=name_and_address)
amount = Amount.objects.all()
suspence = Suspence.objects.all()
total_temp = Amount.objects.aggregate(Sum("total"))
total = int(total_temp['total_sum'])
net_total_temp =
Amount.objects.aggregate(Sum('net_total'))
net_total= int(net_total_temp['net_total__sum'])
template ={'form':form,
'total':total,'title':title ,'sign':sign, 'net_total':net_total,
'client':client,'amount':amount,'suspence':suspence,'name_and_address':name_and_address
,}
return
render_to_response('automation/oldclient.html',locals(),
context_instance=RequestContext(request))
else:
form = OldClientadd()
return render_to_response('automation/client.html', {'form': form},
context_instance=RequestContext(request))
------------------------------------------------------------------------------------------------------------------------------------
Here I get filtered the data of the client I require, from amount and
client table. But when I go for the sum, it add all the data in
amount field without providing any filter.
Is there any way to find aggregate sum of only those amounts that are
previously filtered ?
I cannot give filter on amount as name and address field is not there
in Amounts table.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment