Django: Tuple / Fixed size list of model fields
I'm looking for an elegant way to store a tuple / list in a django model.
My model looks like this:
class MyClass(models.Model):
val_0 = models.SmallIntegerField(default=0)
val_1 = models.SmallIntegerField(default=0)
val_2 = models.SmallIntegerField(default=0)
val_3 = models.SmallIntegerField(default=0)
val_4 = models.SmallIntegerField(default=0)
val_5 = models.SmallIntegerField(default=0)
val_6 = models.SmallIntegerField(default=0)
val_7 = models.SmallIntegerField(default=0)
val_8 = models.SmallIntegerField(default=0)
val_9 = models.SmallIntegerField(default=0)
Is there a more convenient way to create a fixed size list of model fields?
It would be nice to access the field values via my_obj.val [3]
+3
source to share