Django Wizard Form and other view in one page

Django Wizard Form and other view in one page



I'm trying to show a wizard form and a table (that is generated by this form and can be seen in every step) in one page. Is it possible?



I have tried:



urls.py


urlpatterns = [url('', GroupsWizard.as_view(form_list), name = 'index'),]



views.py


def index(request):
groups_render = Groups.objects.all()
return render(request, 'index.html', 'groups_render' : groups_render)

class GroupsWizard(SessionWizardView):

def get_template_names(self):
return 'index.html'

def done(self, form_list, **kwargs):
data = k: v for form in form_list for k, v in form.cleaned_data.items()
instance = Groups.objects.create(**data)
return render(self.request, 'done.html',
'form_data': [form.cleaned_data for form in form_list],
)



index.html


<div>
wizard.form.management_form
% for form in wizard.form.forms %
form
% endfor %
</div>
<div>
groups_render
</div>



Thanks




1 Answer
1



I found it,



I used get_context_data function in views.py:


class GroupsWizard(SessionWizardView):

def get_template_names(self):
return 'index.html'

def get_context_data(self, form, **kwargs):
context = super(GroupsWizard, self).get_context_data(form = form, **kwargs)
context_data = Groups.objects.all()
context.update('context_data': context_data)
return context

def done(self, form_list, **kwargs):
data = k: v for form in form_list for k, v in form.cleaned_data.items()
instance = Groups.objects.create(**data)
return render(self.request, 'done.html',
'form_data': [form.cleaned_data for form in form_list],
)



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế