I think that what you want can be accomplished by: from django.db.models import F
readers = Readers.objects.filter(status=active) readers.update(sorter=(F('library') + F('book')) On Wed, Jul 21, 2010 at 19:40, Nick <nickt...@gmail.com> wrote: > > I am trying to loop through a queryset and assign values to a field > based on other values in that entry. > > So something like this > > readers = Readers.objects.filter(status=active) > > for reader in readers: > library = reader.library > book = reader.book > > readers.update(sorter="%s%s" % (lirbary, book)) > > however, when I run the update it assigns the same value to all of the > readers. I would like this to assign the value to sorter based on > what their individual library and book choices are. > > reader.update return and error "reader has no attribute 'update'" > > -- > 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<django-users%2bunsubscr...@googlegroups.com> . > For more options, visit this group at http://groups.google.com/group/django-users?hl=en. > -- 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.