Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django FormWizard:当有自己的2个模板时,如何从步骤1继续到步骤2_Django_Django Models_Django Forms_Django Templates_Django Views - Fatal编程技术网

Django FormWizard:当有自己的2个模板时,如何从步骤1继续到步骤2

Django FormWizard:当有自己的2个模板时,如何从步骤1继续到步骤2,django,django-models,django-forms,django-templates,django-views,Django,Django Models,Django Forms,Django Templates,Django Views,在formwizard中我有两个步骤。第一步是客户填写他们的特定内容,第二步是构建特定内容 models.py class customer(models.Model): LAST_NAME = models.CharField(max_length = 50) FIRST_NAME = models.CharField(max_length = 50) ADDRESS = models.CharField(max_lengt

在formwizard中我有两个步骤。第一步是客户填写他们的特定内容,第二步是构建特定内容

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],
    })
url.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.htmlcustomer.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>
非常感谢您的帮助……非常需要帮助……两天来一直在努力解决所有这些问题,每次我做更改时,都会出现奇怪的错误


非常感谢您的光临。为我愚蠢的问题道歉

你有时间的时候应该看看PEP8。