added view for multipage form

This commit is contained in:
Benni Bärmann 2020-10-01 12:08:02 +02:00
parent 28204aeab7
commit e66be49e2d
3 changed files with 18 additions and 9 deletions

View File

@ -22,12 +22,12 @@ class VolunteerForm(ModelForm):
model = Volunteer model = Volunteer
fields = '__all__' fields = '__all__'
class LibraryForm: class LibraryForm(ModelForm):
class Meta: class Meta:
model = Library model = Library
fields = '__all__' fields = '__all__'
class IFGForm: class IFGForm(ModelForm):
class Meta: class Meta:
model = 'IFG' model = IFG
fields = '__all__' fields = '__all__'

View File

@ -1,9 +1,9 @@
from django.urls import path from django.urls import path
from . import views from .views import intern, ExternView, done
urlpatterns = [ urlpatterns = [
path('', views.intern, name='intern'), path('', intern, name='intern'),
path('extern', views.extern, name='extern'), path('extern', ExternView.as_view(), name='extern'),
path('saved', views.done, name='done') path('saved', done, name='done')
] ]

View File

@ -1,9 +1,10 @@
from django.shortcuts import render from django.shortcuts import render
from django.forms import modelformset_factory from django.forms import modelformset_factory
from .models import Project
from .forms import ProjectForm
from django.http import HttpResponse from django.http import HttpResponse
from formtools.wizard.views import SessionWizardView
from .forms import ProjectForm, VolunteerForm, LibraryForm
from .models import Project
def intern(request): def intern(request):
# return HttpResponse("Hello, world. You're at the input form") # return HttpResponse("Hello, world. You're at the input form")
@ -28,3 +29,11 @@ def done(request):
def extern(request): def extern(request):
return HttpResponse("The world out there is large and dangerous") return HttpResponse("The world out there is large and dangerous")
class ExternView(SessionWizardView):
template_name = "path/to/template"
form_list = [VolunteerForm, LibraryForm]
def done(self, form_list, **kwargs):
return render(self.request, 'done.html', {
'form_data': [form.cleaned_data for form in form_list],
})