How to determine what you want to display objects on a template of chekox, radio, text?

models.py:
class Question(models.Model):
 section = models.ForeignKey(Section)
 question_text = models.CharField(verbose_name='question')

class Answer(models.Model):
 question = models.ForeignKey(Question)
 answer_text = models.CharField(verbose_name='Answer', max_length=100)
 true = models.BooleanField(verbose_name='true/false')
 points=models.FloatField(verbose_name='Points')


Question can contain as many correct(chekbox) and one right (radio), as well as one right in a text field.

How to determine when output in the template that this question one or more answers?
June 27th 19 at 14:57
2 answers
June 27th 19 at 14:59
class Question add field type ?
yeah, but then when drafting a question, if is not correct the type can be error. - chance26 commented on June 27th 19 at 15:02
June 27th 19 at 15:01
Calculate that into views and pass to the template.
And if you write a method in model.py check the number of child objects have a Question, it would be correct? - chance26 commented on June 27th 19 at 15:04
: or so - chance26 commented on June 27th 19 at 15:07

Find more questions by tags DjangoPython