FormWizard: How to proceed from step 1 to Step 2 when having own 2 templates

 ̄綄美尐妖づ 提交于 2019-12-24 14:12:21

问题


I have 2 steps in formwizard. the first step is where the customer filled up their particular and the second step is about building particular.

models.py

class customer(models.Model): 
    LAST_NAME   = models.CharField(max_length = 50)
    FIRST_NAME  = models.CharField(max_length = 50)               
    ADDRESS     = models.CharField(max_length = 60, blank =True)

    def __unicode__(self):
        return '{0}' % (self)


class building(models.Model):
    CUSTOMER          = models.ForeignKey(customer, null = True, blank = True)
    BUILDING_USE         = models.CharField(max_length = 2, blank = True, choices = c.Anvendelse, default = '02')
    BUILDING_FLOORSPACE  = models.IntegerField(default=0)

    def __unicode__(self):
        return '{0}' % (self)

forms.py

class customerForm(ModelForm):
    FIRST_NAME      = forms.CharField(max_length=50)
    LAST_NAME       = forms.CharField(max_length=50)  
    ADDRESS         = forms.CharField(max_length=60)


class buildingForm(ModelForm):
    CUSTOMER            = forms.CharField(widget=forms.TextInput)
    BUILDING_FLOORSPACE = forms.CharField(widget=forms.TextInput)
    BUILDING_USE       = forms.CharField(widget=forms.TextInput)


class customerWizard(FormWizard):
    def done(self, request, form_list):
        return render_to_response('done.html', {
            'form_data': [form.cleaned_data for form in form_list],
    })

urls.py

url(r'^contact/$', customerWizard.as_view([customerForm, buildingForm])),

I have actually two templates customer.html and building.html How do I do so that I may be able to use my own template. #1 will be displaying customer.html and #2 displaying building.html. when i do this url it gives me the customer.html but when i submit to go to next step it didn't show the building.html but instead showing the customer.html without style.

wizard.html(customer.html copy to wizard.html) some codes...

<div id="tabs-1">
<p>Step {{ step }} of {{ step_count }}</p>
<form action="." method="post"> 
{% csrf_token %}

 {{ form.id }} 

some codes....

<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
{{ previous_fields|safe }}
<input type="submit">
</form>

Help is very very much appreciated......need help badly...kinda trying to figure out all this for 2 days already and every time I do changes then it give me weird error...

Thank you so much in advanced. Sorry for my silly q.

来源:https://stackoverflow.com/questions/15397273/formwizard-how-to-proceed-from-step-1-to-step-2-when-having-own-2-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!