[email protected] wrote: > Hi, > > I hope I understood it right. You could set the field to > editable=False, the rest Django will take care. > > Btw, you have a typo "attachement" should be "attachment" I think. >
Thanks for the info & finding the typo. Setting the field to editable=False would mean i need to specify the fields in the ModelForm and i would like to avoid that if possible. Also, the documentation says that specifying an instance should take care of filling in the missing values: ========quote======= Note If you specify fields or exclude when creating a form with ModelForm, then the fields that are not in the resulting form will not be set by the form's save() method. Django will prevent any attempt to save an incomplete model, so if the model does not allow the missing fields to be empty, and does not provide a default value for the missing fields, any attempt to save() a ModelForm with missing fields will fail. To avoid this failure, you must instantiate your model with initial values for the missing, but required fields: author = Author(title='Mr') form = PartialAuthorForm(request.POST, instance=author) form.save() ========quote======= So why do i get the IntegrityError complaining about null values? Regards, Benedict -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

