我正在尝试从我创建的一个名为“调查”的小应用程序中获取的数据中,找出如何创建人物模型。调查应用程序使用SessionWizardView将调查拆分为多个页面。你知道吗
我总是犯这个错误
File "/Users/brendan/Dropbox/workspace/bias_experiment/src/survey/models.py", line 38, in Person email = forms.SurveyFormA.sender(max_length=200) AttributeError: 'module' object has no attribute 'SurveyFormA' localhost:src brendan$
型号.py
from django import forms
from django.db import models
from survey.forms import SurveyFormA, SurveyFormB
class Person(models.Model):
email = forms.SurveyFormA.sender(max_length=200)
def __unicode__(self):
return self.email
表单.py
这是一个例子的一些问题,我在我的生活中表单.py你知道吗
class SurveyFormA(forms.Form):
sender = forms.EmailField(label='What is your email address?', required = False)
birthdate = forms.DateField(widget=extras.SelectDateWidget(years = range(1995, 1900, -1)), label='What is your Date of Birth?', required = False)
MALE = 'M'
FEMALE = 'FM'
SEX = (
("", "----------"),
(MALE, "Male"),
(FEMALE, "Female"),
)
sex = forms.ChoiceField(widget=forms.Select(), choices=SEX, initial= "", label='What sex are you?', required = False)
class SurveyFormB(forms.Form):
....
more questions here
....
我正在使用Python2.7.3和Django1.6.2(我将很快尝试更新)
我错过了什么?你知道吗
谢谢
在此行中:
窗体表示Django模块。请尝试以下操作:
相关问题 更多 >
编程相关推荐