Actually I don’t know if its possible but this is a rough example of what do I want
its like,
class ImAModel(models.Model):
field_of_list_of_questions = (models.BooleanField(), models.BooleanField(), models.BooleanField())
I need this beacuse I will have a model that have a vary field. And also there may be a lot of fields in it. Then I want to call them like this val = model.field_of_lists_of_questions[1]
It’ll be very enjoying if it’s possible.
>Solution :
No, you can however define three fields, and a property to group these:
class ImAModel(models.Model):
question1 = models.BooleanField()
question2 = models.BooleanField()
question3 = models.BooleanField()
@property
def list_of_questions(self):
return (self.question1, self.question2, self.question3)
@list_of_questions.setter
def list_of_questions(self, value):
self.question1, self.question2, self.question3 = value