That's great - exactly what I needed thanks very much. The key to it was the views code:
for person in people: person.calcs = [ 1, 2, 3 ] I can now assign the calcs reference to a function that returns the result of the calculation for that row, and this can be accessed as part of the queryset loop on the template - perfect. Almost seems too easy not having to physically declare a new field or use a class library method to append it, like in .NET. But I definitely like it this way, much easier! I did try the model manager route again and still had some issues accessing their values from the template, but adding a field with dot notation in the view has done the trick anyway. Thanks again for your help. Regards, wubble u On Mar 12, 3:46 pm, Darren <blogposts.dar...@gmail.com> wrote: > 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 thequerysetso > > I can loop through and display them along with the data from each row. > > > I can't seem to find a way toaddfieldsto thequeryset, 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.