save() prohibited to prevent data loss due to unsaved related object

前端 未结 3 819
情话喂你
情话喂你 2020-12-09 14:52

I need to pass a primary key from a newly created ModelForm to another form field in the same view but I get an error. Any suggestions to make this work? It loo

3条回答
  •  萌比男神i
    2020-12-09 15:10

    Answered - The problem arose from django not saving empty or unchanged forms. This led to null fields on those unsaved forms. Problem was fixed by allowing null fields on foreign keys, as a matter of fact -- all fields. That way, empty or unchanged forms did not return any errors on save.

    FYI: Refer to @wolendranh answer.

提交回复
热议问题