我正在使用带有上下文处理器的两个全局两种形式。
forms.py
from django import forms
class ContactForm1(forms.Form):
subject = forms.CharField(max_length=100)
sender = forms.EmailField()
class ContactForm2(forms.Form):
message = forms.CharField(widget=forms.Textarea)
views.py
from django.http import HttpResponseRedirect
from formtools.wizard.views import SessionWizardView
class ContactWizard(SessionWizardView):
def done(self, form_list, **kwargs):
new = MyModel()
for form in form_list:
new = construct_instance(form, new, form._meta.fields, form._meta.exclude)
new.save()
HttpResponseRedirect('/page-to-redirect-to-when-done/')
contexprocessors.py
from .forms import ContactForm1, ContactForm2
def contact_form1(request):
return {
'contact_form1': ContactForm1()
}
def contact_form2(request):
return {
'contact_form2': ContactForm2(),
}
如何通过上下文处理器传递向导变量?