The line of my previous post " print i.name" should read "print i.firstname
This is just a correction to my post, not to my problem! Thanks MerMer Merric Mercer wrote: > I'm getting, what seems to me, an inconsistency. > Here's a simplified example: > > > >>qs=Mymodel.objects.all() > >>for i in qs: > setattr(i,"firstname","merric") > > This works on:- > > >>qs[0].firstname > >>merric > > It also works in the template:- > > {% for i in qs %} {{ i.firstname }} {% endfor %} > > so I don't understand why this doesn't seem to work after I've set the > new attribute:- > > >> for i in qs: > print i.name > >> Attribute Error 'QuerySet' object has no attribute 'merric'. > > Am I doing something fundamentally wrong? If not this seems rather > inconsistent. If I can iterate through an altered QuerySet in my > template why can't I do > so in the code? > > My problem is this:- > > I have a query set that I need to filter, but only after I've done a > bunch of dynamic calculations on other related data. Is there an easy > way to alter the query set dynamically and effectively? > > Thanks > > MerMer > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---