开发者

Django Form Wizard and Preview with ModelForm

开发者 https://www.devze.com 2022-12-11 17:26 出处:网络
I have a large Django model (73 fields) that will will be connected to a ModelForm. I\'d like to use a combination of the functionality found the Form Wizard and Form Preview contrib apps.

I have a large Django model (73 fields) that will will be connected to a ModelForm. I'd like to use a combination of the functionality found the Form Wizard and Form Preview contrib apps.

I.e., the form fields would be split over multiple pages, and the user would have a chance to review/preview the d开发者_Python百科ata before the model instance is created.

Are there any best-practices for this type of thing, or example code?


I do a similar thing at my first Django project. Using session-based FormWizard, I customized it so user can stop subbmiting data at any form.

At that point you can use FormPreview probably to show information or just dynamically generate form and show it to user. Data stays in the session.


You can pass the entire dictionary to the context and then access it in your template:

# views.py
def get_context_data(self, **kwargs):
    context = super(MyWizard, self).get_context_data(**kwargs)
    context['all_data'] = self.get_all_cleaned_data()
    return context

# template.html
{{ all_data }}
0

精彩评论

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