No, it is not just those fields, there are about 20 key-value items. I
have a Database with about 40 tables. and I am essentially trying to
render a snapshot of about 15 important table which had foreign key
relationship with other tables. Following will give you an idea of
what I am trying to do. Thanks
--------template ---
<div class = "module">
<div class = "module">
<h2> User details </h2>
<table cellspacing = "0">
{% for i in user_details.items %}
<tr scope = "row" class="{% cycle 'row1' 'row2' %}">
<th>{{i.0}}</
th><td> {{i.1}}</td></tr>
{% endfor %}
</table>
</div>
<div class = "module">
<h2> Order details </h2>
<table cellspacing = "0">
{% for i in order_details.items %}
<tr scope = "row" class="{% cycle 'row1' 'row2' %}">
<th>{{i.0}}</
th><td> {{i.1}}</td></tr>
{% endfor %}
</table>
</div>
:
:
:
</div>
-----------views.py---------
if request.method == 'POST':
user_id = request.POST["user_id"]
user = Users.objects.get(pk=user_id)
user_details['Name'] = user.name
user_details['Login'] = user.login
user_details['Phone No.'] = user.phone_number
user_entity =
UserEntities.objects.all().filter(owner=user_id)
total_user_profit = sum([obj.profit for obj in
user_entity])
total_user_loss = sum([obj.loss for obj in user_entity])
trader_acct_details['Total profit'] = total_user_profit
trader_acct_details['Total loss'] = total_user_profit
orders = Orders.objects.get_todays_orders(user_id)
new_order_count = sum([obj.quantity for obj in
orders.filter(order_state ='N')])
order_details['New Orders'] = new_order_count
:
:
:
return render_to_response('admin/
Snapshot.html', { 'user_details': user_details, 'user_acct_details':
trader_acct_details, 'order_details': order_details })
On Aug 28, 11:49 am, David Zhou <[EMAIL PROTECTED]> wrote:
> On Aug 28, 2008, at 12:45 PM, saeb wrote:
>
> > order is important for display, I am calculating sum and average on
> > query objects and storing it in dictionary with key/values which are
> > used in a template. So I have a dictionary something like this :
> > {'name': user1, 'phone': 723872, 'Total Friends': 20, 'Avg Rating' :
> > 3.6}
> > so when I render I would these to appear in order.
>
> Can you post the relevant view and template code?
>
> But if it's just those fields, why not refer to them explicitly? Such
> as:
>
> {{dict_variabe.name}} or {{dict_variable.phone}}
>
> ---
> David Zhou
> [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---