On Jan 8, 3:03 am, Car <[EMAIL PROTECTED]> wrote: > 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() > > Exeption after executing this lines: > > Exception Value: (1048, "Column 'useradd_id' cannot be null")
This should help you: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser Best regards, l. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---