views:

1065

answers:

1

Hi guys, i have a question about the choices option field.

i have this field:

SECUENCIA = (
             ('1','1'),
             ('2','2'),
             ('3','3'),
)
secuencia = models.IntegerField(max_length=1,choices=SECUENCIA)

All is fine in my forms for add or update but in my show view (template display) the field just appear like "(None)" and dont show the value (1 or 2 or 3).

Thanks :)

+7  A: 

The first element of your choice tuple has to be the value that will be stored. In your case, it needs to be an integer:

SECUENCIA = (
             (1, '1'),
             (2, '2'),
             (3, '3'),
)

See the documentation for more information:

ars
Thanks ars for reply :)
Asinox
Glad to help! :)
ars