在Django建立问卷

时间:2011-10-16 21:17:16

标签: django

我正在尝试构建一个Django调查问卷。我有用户注册和登录。 一旦他登录,每个用户将拥有他必须参加的一组课程 回答问卷。每个问题可能有不同类型的选择。我怎么发帖 基于他上过哪些课程的问题?

class Aulas(models.Model):
    title = models.CharField(max_length=200) #classes he attended[title of the class]
    def __unicode__(self):
        return '%s' % (self.title)
''' this were i add classes the student attends '''
class Questions(models.Model):
    question= models.CharField(max_length=500)
    aula    = models.ForeignKey(Aulas)
    choice_type = models.CharField(max_length=10)       
    def __unicode__(self):
        return '%s %s %s' % (self.question,self.aula,self.choice_type)
''' here i add questions and choice type '''
class Answer(models.Model):
    answer=models.CharField(max_length=20)
    questions=models.ForeignKey(Questions)
    user=models.ForeignKey(User)
    def give_choices(self,ANSWER_CHOICES):
        self.answer=models.CharField(max_length=20,choices=ANSWER_CHOICES)
def __unicode__(self):
        return '%s %s %s' % (self.answer,self.questions,self.user)

我在数据库中添加了所有问题。我的问题是如何创建页面 我是否可以根据课程(Aula)过滤问题,以便用户可以 回答这些问题。 我应该创建一个forms.py,还是我可以在views.py本身进行管理。

0 个答案:

没有答案