我试图为给定问题组中的每个问题创建一个表单域。我对python/django非常陌生,所以这可能是一种不好的方法,欢迎提出高层次的建议。以下是我所拥有的:
在模型.py公司名称:
class QuestionGroup(models.Model):
name = models.CharField(max_length = 50)
creator = models.ForeignKey(User)
modified = models.DateTimeField()
class Question(models.Model):
question_content = models.CharField(max_length = 100)
question_group = models.ForeignKey(QuestionGroup)
在视图.py公司名称:
^{pr2}$在表单.py公司名称:
class ResponseForm(forms.Form):
def __init__(self, *args, **kwargs):
for q in args:
q.question_content = forms.CharField(max_length = 100)
我得到“'ResponseForm'对象没有属性''u errors'”。思想?在
不确定这是否是这里的问题,但您可能应该在重写的\uyu init\uu中调用父窗体初始化方法:
相关问题 更多 >
编程相关推荐