我试图弄清楚如何从我创建的名为“survey”的小应用程序中获取的数据创建Person模型。调查应用程序使用SessionWizardView将多个页面上的调查分开。
我一直收到此错误
文件 “/Users/brendan/Dropbox/workspace/bias_experiment/src/survey/models.py” 第38行,在人 email = forms.SurveyFormA.sender(max_length = 200)AttributeError:'module'对象没有属性'SurveyFormA'localhost:src brendan $
models.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
forms.py
这是我在forms.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
....
我正在使用Python 2.7.3和Django 1.6.2(我将尽快更新)
我在这里缺少什么?
由于
答案 0 :(得分:0)
在这一行:
email = forms.SurveyFormA.sender(max_length=200)
表单代表Django模块。试试这个:
email = SurveyFormA.sender(max_length=200)