I have the following models:
POSSIBLE_POSITIONS = (
(1, 'Brazo'),
(2, 'Muñeca'),
(3, 'Pierna'),
(4, 'Pie'),
)
class Device(models.Model):
id = models.CharField(max_length=10, primary_key=True)
class User(models.Model):
id = models.CharField(max_length=10, primary_key=True)
device = models.ForeignKey(Device, blank=True, null=True, on_delete=models.SET_NULL)
position = models.CharField(max_length=1, choices=POSSIBLE_POSITIONS, default=1)
I would like to know how to work with that dictionary. If I go to Django shell and I do the following it works:
user = User(pk=1, position=12312)
Why this work? 12312 is not a possible choice from POSSIBLE_POSITIONS.
How can I exchange the number for the String?
Also, how can I show all this options on a selector when creating a new user via html?