D
D
Denis Pupchenko2017-04-08 16:43:31
Django
Denis Pupchenko, 2017-04-08 16:43:31

How to determine that you need to display objects on the template in the form of chekox, radio, text?

models.py:

class Question(models.Model):
    section = models.ForeignKey(Section)
    question_text = models.CharField(verbose_name='Описание вопроса')

class Answer(models.Model):
    question = models.ForeignKey(Question)
    answer_text = models.CharField(verbose_name='Ответ', max_length=100)
    true = models.BooleanField(verbose_name='true/false')
    points=models.FloatField(verbose_name='Баллы')

The question can contain both a set of correct ones (chekbox) and one correct one (radio), as well as one correct one in the form of a text field.
How to determine when outputting to a template that a given question has one or more answer options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Pavlyuchuk, 2017-04-08
@bort95

add a type field to the Question class?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question