the simplest method should work, perhaps you made a mistake early on
which set you off on the wrong path?

class Person(models.Model):
    name = models.CharField(max_length=100)

def view_func(request):
    people = Person.objects.all()
    for person in people:
        person.calcs = [ 1, 2, 3 ]
    return render_to_response('people.html', { 'people':people })

{% for person in people %}
        {{ person.name }}
        {% for c in person.calcs %}
            {{ c }}
        {% endfor %}
        <br>
{% endfor %}

- is this what you're after?

Darren

On Mar 11, 5:10 pm, wubble u <danmouseonm...@googlemail.com> wrote:
> Hi All,
>
> I've been passing querysets to templates for looping through rows to
> create tables / lists on the page... nice and easy... but I need to
> perform calculations on these rows and pass them with the queryset so
> I can loop through and display them along with the data from each row.
>
> I can't seem to find a way to add fields to the queryset, so I've
> tried creating a list of lists/dictionaries manually, and adding the
> data this way and then passing the list, but not having much luck here
> either.
>
> Then I tried tackling it at the model level using managers and model
> methods, but can't seem to access the data from the template.
>
> I'm from a .NET background so I'm used to populating datatables and
> adding columns and moving them around nice and easily, so I guess I'm
> probably just going about it the wrong way...
>
> Anyone got any ideas as to the pythonic way of accomplishing this?
>
> Cheers,
> wubble u

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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