From e66be49e2d2cc6e3ccfe5334b79ce393e7a17b60 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 1 Oct 2020 12:08:02 +0200 Subject: [PATCH] added view for multipage form --- input/forms.py | 6 +++--- input/urls.py | 8 ++++---- input/views.py | 13 +++++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/input/forms.py b/input/forms.py index 7c33a8a..19efbac 100644 --- a/input/forms.py +++ b/input/forms.py @@ -22,12 +22,12 @@ class VolunteerForm(ModelForm): model = Volunteer fields = '__all__' -class LibraryForm: +class LibraryForm(ModelForm): class Meta: model = Library fields = '__all__' -class IFGForm: +class IFGForm(ModelForm): class Meta: - model = 'IFG' + model = IFG fields = '__all__' diff --git a/input/urls.py b/input/urls.py index f886e9c..fb9007d 100644 --- a/input/urls.py +++ b/input/urls.py @@ -1,9 +1,9 @@ from django.urls import path -from . import views +from .views import intern, ExternView, done urlpatterns = [ - path('', views.intern, name='intern'), - path('extern', views.extern, name='extern'), - path('saved', views.done, name='done') + path('', intern, name='intern'), + path('extern', ExternView.as_view(), name='extern'), + path('saved', done, name='done') ] diff --git a/input/views.py b/input/views.py index 301821f..1b59cec 100644 --- a/input/views.py +++ b/input/views.py @@ -1,9 +1,10 @@ from django.shortcuts import render from django.forms import modelformset_factory -from .models import Project -from .forms import ProjectForm from django.http import HttpResponse +from formtools.wizard.views import SessionWizardView +from .forms import ProjectForm, VolunteerForm, LibraryForm +from .models import Project def intern(request): # return HttpResponse("Hello, world. You're at the input form") @@ -28,3 +29,11 @@ def done(request): def extern(request): 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], + })