tags:

views:

18

answers:

3

If I have a GENDER_CHOICE Tuple in a model like so:

GENDER_CHOICES = (
    ('M', 'Male'),
    ('F', 'Female'),
)

Could I use Integers a swell:

GENDER_CHOICES = (
    ('1', 'Male'),
    ('2', 'Female'),
)

And have a IntegerField(max_length=1) to write to ?

Thanks.

A: 

Yes, you can do that, but you are not using integers in your example, but strings representing one digit integers.

gruszczy
A: 

I think a PositiveSmallIntegerField would be a better fit.

Manoj Govindan
A: 

Absolutely, but '1' and '2' are not integers (although they might still work through some magic).

This would definitely work for an IntegerField:

GENDER_CHOICES = (
    (1, 'Male'),
    (2, 'Female'),
)

I don't believe an IntegerField has a max_length attribute. A PositiveSmallIntegerField would be appropriate if you want a small number of choices.

Ben James
cool thanks a lot !
MacPython