小编Mid*_*di_的帖子

带有模板的自定义 Django FormWizard 步骤

这是我按照这个这个制作的工作 FormWizard

视图.py

from django.shortcuts import render
from django.template import RequestContext
from django.http import HttpResponseRedirect
from formtools.wizard.views import SessionWizardView

# Create your views here.
def index(request):
    return render(request, 'wizardApp/index.html')

class ContactWizard(SessionWizardView):
    template_name = "wizardApp/contact_form.html"
    def done(self, form_list, **kwargs):
        process_form_data(form_list)
        return HttpResponseRedirect('../home')

def process_form_data(form_list):
    form_data = [form.cleaned_data for form in form_list]

    print(form_data[0]['subject'])
    print(form_data[0]['info1'])
    print(form_data[0]['info2'])
    print(form_data[1]['sender'])
    print(form_data[1]['info1'])
    print(form_data[1]['info2'])
    print(form_data[2]['message'])
    print(form_data[2]['info1'])
    print(form_data[2]['info2'])

    return form_data
Run Code Online (Sandbox Code Playgroud)

网址.py

from django.conf.urls import url
from wizardApp import views

from wizardApp.forms import ContactForm1, ContactForm2, ContactForm3 …
Run Code Online (Sandbox Code Playgroud)

python forms django templates django-formwizard

2
推荐指数
1
解决办法
2535
查看次数

标签 统计

django ×1

django-formwizard ×1

forms ×1

python ×1

templates ×1