Re: Update a single column of a row in a Model

2010-03-05 Thread Ken
Many thanks Karen. This worked perfectly (though the 'name' attribute is just name without the quotes). Cheers, Ken On 5 Mar, 01:42, Karen Tracey wrote: > On Thu, Mar 4, 2010 at 2:24 PM, Ken wrote: > > Thanks for your example, but whilst you're correct about Person.id not > > getting updated

Re: Update a single column of a row in a Model

2010-03-04 Thread Karen Tracey
On Thu, Mar 4, 2010 at 2:24 PM, Ken 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.Cha

Re: Update a single column of a row in a Model

2010-03-04 Thread Ken
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_obj

Re: Update a single column of a row in a Model

2010-03-04 Thread Shawn Milochik
1. Doing Person.save() will NOT update every field in your model. 2. Your snippet uses a ModelForm. Mine used a Form. There's a huge difference. If you use a ModelForm you're going to have to exclude all the fields you don't want. 3. If you use a ModelForm and instantiate it with request.POST, d

Re: Update a single column of a row in a Model

2010-03-04 Thread Ken
Thanks Shawn My problem is that Person.save() will do an update of all my columns. Even though they are all identical, apart from the changed value, this will violate my minimum privileges requirement of only allowing the application access to the columns that it is allowed to change - hence your

Re: Update a single column of a row in a Model

2010-03-04 Thread Shawn Milochik
Here's a simple example. It could be improved, but it's meant to be very simple. #Make a simple form. class AgeForm(forms.Form): age = forms.IntegerField() #When the user submits the form: age_form = AgeForm(request.POST) if age_form.is_valid() #get the pk however you need to

Re: Update a single column of a row in a Model

2010-03-04 Thread Ken
Thanks Unfortunately I'm very new to Forms/ModelForms, and I'm having a lot of difficulty understanding the Django examples. All I want is to allow my users to make one change to one column. I don't want them to see the ID, just a text box and a submit button. Hitting Submit should take them bac

Re: Update a single column of a row in a Model

2010-03-02 Thread Shawn Milochik
Use a forms.ModelForm and exclude all the fields except one, or use a forms.Form with one field and use its value in a queryset .update() call. Shawn Sent from my iPhone On Mar 2, 2010, at 7:11 PM, Ken wrote: Folks This is a bit of a newbie question on Model updates. I've been happily