django - Questionnaire App, creating list models -


i trying create questionnaire app. each question in questionnaire have multiple possible answers choose , user can answer chosing answer suits him

ex : if debutant django debutant ask do ?

  1) him no matter    2) give him direction solve problem   3) pass on 1 no time if nobody answer swear answer later   4) nobody helped me, won't either  

user answer : 1 , 2

now designed model following :

from django.db import models registration.models import myuser  # create models here. class questionnaire(models.model):     question = models.charfield(max_length=600)     possible_answer_number = models.integerfield()     multiple_answer = models.booleanfield(default=false)      def __str__(self):         return self.question  class answers(models.model):     question_id = models.foreignkey('questionnaire', on_delete=models.cascade)     answer = models.charfield(max_length = 600)      def __str__(self):         return self.answer  class test(models.model):      user = models.foreignkey('registration.myuser')     created_at = models.timefield(auto_now_add=true)     closed = models.booleanfield(default=false)  class useranswer(models.model):     test_id = models.foreignkey('test')     question = models.foreignkey('questionnaire')     answer = models.foreignkey('answers') 

i not sure if best way structure models .. guess best way have list answer each question how can ?

thx you


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -