Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select a Valid Choice. 0 is not one of the available choices

Tags:

django

TYPE1 = 0
TYPE2 = 1

OPEN_TYPES = (
    (TYPE1, _(u"Test")),
    (TYPE2, _(u"Test2")),
)

models:

models.CharField(max_length=10, choices=OPEN_TYPES)

I have this error if I try to add object in admin panel:

Select a Valid Choice. 0 is not one of the available choices

How to fix it?

like image 856
mamasi Avatar asked May 15 '14 15:05

mamasi


2 Answers

You're using integer values with a CharField. You have to either use the values '0' and '1' or change it to an IntegerField.

like image 124
knbk Avatar answered Nov 08 '22 04:11

knbk


Use a default value also that will work!

like image 33
rg8143 Avatar answered Nov 08 '22 04:11

rg8143