Browse Source

added view for multipage form

master
Benni Baermann 4 years ago
parent
commit
e66be49e2d
3 changed files with 18 additions and 9 deletions
  1. +3
    -3
      input/forms.py
  2. +4
    -4
      input/urls.py
  3. +11
    -2
      input/views.py

+ 3
- 3
input/forms.py 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__'

+ 4
- 4
input/urls.py 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('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')
] ]

+ 11
- 2
input/views.py 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],
})

Loading…
Cancel
Save