You should look into making a foreign key relationship if there actually is 
one. That way you can just annotate the the sums. Otherwise you should 
calculate the sum in the view (NOT the template) and add it to the client. 
Python allows you to add any value you want to any object.

On Feb 3, 2012, at 7:38 AM, Sandeep kaur wrote:

> On Fri, Feb 3, 2012 at 7:52 PM, Weldan <mwel...@gmail.com> wrote:
>> Entries.objects.count()
>> 
> That will be applicable if I want to his for only 1 table's entry.
> But here I have views as :
> 
>                       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()
> 
> and for this I have template as :
> 
>   {% if client %}
>    {% for clients in client %}
>    {% for amounts in amount %}
> 
>         {% if clients.job_no == amounts.job_no %}
> 
>         {% if clients.name_and_address == clients.name_and_address %}
> 
>                       <td>{{ clients.receipt_no }}</td>
>                       <td> {{ clients.date }}</td>
>                        <td ALIGN="right">{{amounts.total}}</td>
>                       <td ALIGN="right">{{amounts.net_total}}</td>
>               {% endif  %}    
> 
>                {% endif  %}
>               </tr>
>        {% endfor %}
> 
>        {% endfor %}
> {% endif %}
> 
> 
> When all this is applied, it creates a view out of 2 tables i.e Amount
> and ClientJob without using foreign key. Now I want to have sum of the
> total and net_total fields for the views generated.

Peter of the Norse
rahmc...@radio1190.org



-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to