开发者

Django ModelForm Wizard - How to create the database object?

I have a Model enought big to be cut in 3 Forms. I wanted to use FormWizzard 开发者_开发技巧to do that and I am wondering, how to save the information from the form to the database?

Everything is from the same model.

Do you have any idea of how to do that ?


There is no clear/direct way to do this.

However, you could hack around to achieve the desired functionality;

I can think of doing it this way:

  • Create n (the number of pages of wizard you want) modelforms of the same model, but with different fields and extra on the meta class.
  • Override the save of the first (n-1) model forms to just pass
  • Override the save of the last form to create a new model with the data from all n wizard forms, and call super.

However, as I said, this is really a "hack" and it may be clearer and pythonic to use different views, forms and the session.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜