1

我在表单向导中有两个步骤。第一步是客户填写他们的具体信息,第二步是建立具体信息。

模型.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)

表格.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],
    })

网址.py

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

我实际上有两个模板 customer.html 和 building.html 我该怎么做才能使用我自己的模板。#1 将显示 customer.html,#2 将显示 building.html。当我执行此 url 时,它给了我 customer.html,但是当我提交进入下一步时,它没有显示 building.html,而是显示没有样式的 customer.html。

wizard.html(customer.html 复制到wizard.html) 一些代码...

<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>

非常感谢帮助......非常需要帮助......有点想弄清楚这一切已经两天了,每次我做改变时它都会给我一个奇怪的错误......

非常感谢您。对不起我的傻q。

4

0 回答 0