0
質問したい質問がいくつあるかをユーザーに尋ねます。彼らの応答に基づいて、私はそれらの多くのフィールドでモデルを設定したい。モデルDjangoで変数フィールドを作成する
from __future__ import unicode_literals
from django.db import models
class Interview(models.Model):
title = models.TextField()
description = models.TextField()
number_questions = models.IntegerField()
question_one = models.ForeignKey('Question', related_name='question_one')
question_two = models.ForeignKey('Question', related_name='question_two')
question_three = models.ForeignKey('Question', related_name='question_three')
question_four = models.ForeignKey('Question', related_name='question_four')
question_five = models.ForeignKey('Question', related_name='question_five')
class Question(models.Model):
question_description = models.TextField()
prep_time = models.IntegerField()
response_time = models.IntegerField()
は、私は、ユーザーが質問のプリセット数に制限されている)ため、およびb)ユーザーが5未満を指定した場合、このソリューションは非効率的であることを認識し、次のように私は現在、それをやって考えています方法です質問には、不要な質問項目が作成されています。複数の質問を保存するより良い方法は何ですか?