On May 24, 5:49 pm, Martin <mb0...@googlemail.com> wrote:
> Hi,
>
> I'm struggling with a simple edit-form. My model has a user-FK and
> authenticated users can 'create' objects of this model with a form.
> Pretty simple. They should be able to edit these objects later, but of
> course not change the value of the user-field. So I excluded the
> 'User'-field in my ModelForm. I thought when I exclude a field from a
> form it just keeps it's value when I call save() on the form. But I
> always get this error when trying to save a valid form:
>
>       ' null value in column "User_id" violates not-null constraint '

If you intend your form to save changes to an existing object, you
must pass that object in as 'instance' when creating the form. The
reference is here:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#creating-forms-from-models

Post your view if you are still having trouble.

sdc

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