On 2008-01-07 19:03:21 -0700, Car <[EMAIL PROTECTED]> said:

> 
> Hello
> 
> I have following code;
> 
> class PlaceForm(ModelForm):
>     class Meta:
>         model = Place
>         exclude = ('useradd',) #excluded, because form shouldn't give
> a way to set user manually
> 
> Model Place has one foreign key to django User model (useradd)
> 
> Is it possible to add field formerly excluded in ModelForm in view
> like in this example below:
> 
> newplace = form.save(commit="False")
> newplace.useradd = request.user   #excluded in PlaceForm
> newplace.save()

Wow, you are so close to making this work :) You are passing in "False" 
to commit which will always be a True statement. Remove the quotes to 
pass in the boolean value False. It should then work.

> 
> Exeption after executing this lines:
> 
> Exception Value:      (1048, "Column 'useradd_id' cannot be null")
> 

-- 
Brian Rosner
http://oebfare.com



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to