Re: existing data failing validation

2011-05-15 Thread Greg Donald
On Sun, May 15, 2011 at 10:24 AM, Shawn Milochik wrote: > I think the reason you're getting the error you are is that you didn't add > 'company' to 'exclude' in your modelform. > > The code you pasted indicates that you will have an existing object 100% of > the time in this view. If that's the ca

Re: existing data failing validation

2011-05-15 Thread Shawn Milochik
I think the reason you're getting the error you are is that you didn't add 'company' to 'exclude' in your modelform. The code you pasted indicates that you will have an existing object 100% of the time in this view. If that's the case, your line to instantiate the form with request.POST and th

Re: existing data failing validation

2011-05-15 Thread Greg Donald
On Sat, May 14, 2011 at 7:35 PM, Shawn Milochik wrote: > That 'name = Charfield' doesn't belong there at all. > > Replace that line with this: >    exclude = ['company'] > > If you did want to add extra fields to a ModelForm you'd put them at the top > -- the same place as you would in a Form. Jus

Re: existing data failing validation

2011-05-14 Thread Shawn Milochik
On 05/14/2011 08:09 PM, Greg Donald wrote: I have from django.db import models from django.forms import ModelForm class Contact( models.Model ): company = models.ForeignKey( Company ) name = models.CharField( max_length=32 ) class ContactForm( ModelForm ): class Meta:

Re: existing data failing validation

2011-05-14 Thread Greg Donald
On Sat, May 14, 2011 at 6:56 PM, Shawn Milochik wrote: > 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

Re: existing data failing validation

2011-05-14 Thread Shawn Milochik
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 m

existing data failing validation

2011-05-14 Thread Greg Donald
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