Hi,
I apologize for possible off-topic, but since Jacob already answered
your question, please allow me to add another hint:

Book.objects.filter(published=False).update(published=True)

would do the same in single query, updating "published" field only (even in 
<1.5).


Cheers,
  Tom


Dne Wed, 14 Aug 2013 10:17:04 -0500
Jacob Kaplan-Moss <ja...@jacobian.org> napsal(a):

> It's not a bug; that is by design.
> 
> However, it's not perfect, so in 1.5 we added update_fields:
> https://docs.djangoproject.com/en/1.5/ref/models/instances/#specifying-which-fields-to-save
> 
> Jacob
> 
> 
> On Wed, Aug 14, 2013 at 7:01 AM, Dong Wang <chinuxw...@gmail.com> wrote:
> 
> > Hi all,
> >
> > I'm using Django 1.4.2. Please let me start my question by an example:
> >
> > books = Book.objects.filter(published=False)
> > for book in books:
> >  book.published=True
> > book.save()
> >
> > I would think this small snippet of code will only update the "published"
> > field, but actually it write all the cached field values back to the
> > database.
> >
> > Is it a bug or designed to be this way?
> >
> > Thanks
> > --
> > Dong Wang
> >
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> 

Attachment: signature.asc
Description: PGP signature

Reply via email to