On Thu, Mar 4, 2010 at 2:24 PM, Ken <ken.w.sm...@gmail.com> wrote:

> Thanks for your example, but whilst you're correct about Person.id not
> getting updated, all the other columns do get changed (even if it is
> to the same value).
>
> Here's my code...
>
> class TcsDetectionListsForm(forms.Form):
>    name = forms.CharField()
>
> def candidateWithForm(request, tcs_transient_objects_id):
>    detectionListRow = TcsDetectionLists.objects.get(pk=0)
>
>
   if request.method == 'POST':
>        form = TcsDetectionListsForm(request.POST)
>        if form.is_valid(): # All validation rules pass
>            detectionListRow.name = form.cleaned_data['name']
>            detectionListRow.save()
>    else:
>        form = TcsDetectionListsForm(initial={'name':
> detectionListRow.name })
>
> Here's what happened in the database (from the DB log):
>
> 223592 Query    UPDATE `tcs_detection_lists` SET `name` = 'rubbish',
> `description` = 'Bad Candidates' WHERE `tcs_detection_lists`.`id` = 0
>
> We shouldn't be updating the 'description' column.  If my security
> settings were in place, this query would fail, because my DB user only
> has update access to the 'name' column.
>

TcsDetectionLists.objects.filter(pk=0).update('name'=form.cleaned_data['name'])

will produce an SQL UPDATE that only touches the name column.

Karen

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

Reply via email to