5👍
I probably should be just commenting on Manoj’s answer, but sounds you need code
urls.py
from django.conf.urls.defaults import *
from MyApp import views
urlpatterns = patterns(
'',
(r'^wizard/$', views.MyWizardView ),
)
views.py
@login_required
def MyWizardView (request):
cw = MyWizard([WizardName, WizardQuestions, WizardProvider, WizardGoomber])
return cw(request)
2👍
The as_view
function converts a class based view into a callable view:
from django import forms
from django.contrib.formtools.wizard.views import SessionWizardView
class Form1(forms.Form):
a = forms.CharField()
class Form2(forms.Form):
b = forms.CharField()
class MyWizard(SessionWizardView):
pass
wizard_view = MyWizard.as_view([Form1, Form2])
def view(request):
# do something fancy with the request object here
return wizard_view(request)
This is basicly the same answer as in How to wrap a Django Form Wizard in a View?
- [Django]-How Do I Handle Ampersands in Django URLs?
- [Django]-How to ensure at least one of the Fields is not blank in Serializer?
- [Django]-Validate specific field in DRF serializer
0👍
This Django snippet may prove useful.
From the title: “FormWizard inside view with proper context handling and site templating support, without having to use urls.py“
- [Django]-How to query for distinct groups of entities which are joined via a self-referential many-to-many table?
- [Django]-Create Nested Serialier Multi Objects in Django Rest Framework?
- [Django]-Django Query, filter by user group
Source:stackexchange.com