Django makes always (at least currently) full record update (iow: there is
no dirty flag for fields).

Example given is "poor" in the sense that it uses directly POST data. I
strongly would suggest leveraging modelforms when ever possible - it saves
time and nerves. You get all the validation and other goodies for free.

On Wed, Jul 11, 2012 at 8:09 PM, Dennis Lee Bieber <wlfr...@ix.netcom.com>wrote:

> On Wed, 11 Jul 2012 08:36:39 -0700 (PDT), JJ Zolper
> <codinga...@gmail.com> declaimed the following in
> gmane.comp.python.django.user:
>
>
> > So originally:
> >
> >         selected_choice = p.choice_set.get(pk=request.POST['choice'])
> >
>         If I understand this (I've not run the tutorial, and only browsed
> the now-outdated print books), this statement is using the value from
> the "choice" field of the submitted form as the primary key to retrieve
> a record (model instance) from the database.
>
> pseudo-SQL
> select * from choice_set where pk = "request.POST['choice']"
>
> > this requests the submitted choice from the POST data and
> >
> > The part that says:
> >
> >         selected_choice.votes += 1
> >         selected_choice.save()
> >
> > Actually saves the choice to the database?
> >
>         This then increments the votes field of the record (model instance)
> retrieved from the database, and then saves the record back.
>
> p-SQL
> update choice_set set
>         votes = votes + 1
> where pk = selected_choice.pk
>
> {I don't know if Django is smart enough to only update the changed
> field, or if it updates the entire record}
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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 
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