I need to ask the user for two security questions and their corresponding answers. The security questions will be provided by me, so it will be some kind of <select>. I created a model to store the user profile named UserProfile. It looks like:
class UserProfile(models.Model):
phone1 = models.CharField(help_text='Primary phone number')
phone2 = models.CharField(help_text='Secondary phone number', blank=True)
...
I could do something like:
SECURITY_QUESTIONS_CHOICES = (
('PN', 'What is your telephone number?'),
('BF', 'What is the full name of your best friend?'),
...
)
and add the following two fields to my model:
question1 = models.CharField(choices=SECURITY_QUESTIONS_CHOICES)
question2 = models.CharField(choices=SECURITY_QUESTIONS_CHOICES)
but I want to be able to modify the list of security questions, so I want it to be a model too.
My question is:
What is the best way of having two fields that point to the same model?
- Having only one field (eg.
questions) which is a ManyToMany relationship toSecurityQuestion, and restricting the number to 2 in the registration form? - Having two fields (
question1andquestion2) where each one is aForeignKeytoSecurityQuestion?
I would prefer create a separate model for all security questions. It gives you flexibility.