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:
         model = Contact
         name = CharField( required=True )

The fields failing validation are ones I'm not re-submitting back in
my edit form.  Am I supposed to list company again in my ContactForm
class?  Guess I can go try it.



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. Just FYI -- you don't need one here.

Shawn

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