On 12/12/07, l5x <[EMAIL PROTECTED]> wrote: > > Hello, > > I have a model with two ForeignKeys (User and another model). I cannot > set them to editable=False, because Admin needs to see them and > modify. > > So I've created ModelForm and excluded those two fields. And now: > > 1) when I'm trying to *update* the content by MyModelForm.save() : > there is error that foreignkeys cannot be null > 2) i thought that it saves (inserts) if there isn't any record > already , and if there is - it just updates - but it does not(?) see > 1) > 3) i've tried to assign these values manually: > > full = Full() > form_full = FullForm(full, request.POST) > > form_full.my_first_fk = 2 > form_full.my_second_fk = 3 > form_full.save()
The code above is just assigning arbitrary attributes to the form object, not the model object. You probably want something more like this: full = Full(my_first_fk=2, my_second_fk=3) form_full = FullForm(full, request.POST) new_full = form_full.save() Joseph --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---