On 05/14/2011 07:51 PM, Greg Donald wrote:
How does one handle non-changing existing data when updating a form?

My 'add' form includes several fields my 'edit' form does not.  For
example once I create a contact and assign it a company_id foreign
key, it will never change.  So when I implement my edit method in my
view, I get errors about not providing fields already set.

form = ContactForm( request.POST, instance=contact )

form.errors says I need to provide a company, but it is already saved
in the database.

What am I missing here?



If you're using forms.Form objects instead of forms.ModelForm objects then that would explain it. If you're dealing with a model then you should probably be using a ModelForm.

To have a ModelForm that doesn't show certain fields just add a Meta section and set the field names in an iterable named 'exclude'.


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