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 original suggestion of using ModelForms (and only specified
fields).

Maybe if I try something like this...


#Use a ModelForm for Person..
class PersonForm(forms.ModelForm):
    model=Person
    fields = ('age')

#When the user submits the form:
person = Person.objects.get(pk = 123)
person_form = PersonForm(request.POST, instance = person)
if person_form.is_valid()
        person_form.save()

Would that work...?  I'll attempt to hack an example in my code and
tell you what happens...

Thanks for your time...

Ken


On 4 Mar, 17:28, Shawn Milochik <sh...@milochik.com> wrote:
> 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
>         person = Person.objects.get(pk = 123)
>         person.age = age_form.cleaned_data['age']
>         person.save()

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