|
Posted by rocjojo |
|
|
Hello,
I would like to to use mysql Enum type in Django. YEAR_IN_SCHOOL_CHOICES = ( ('FR', 'Freshman'), ('SO', 'Sophomore'), ('JR', 'Junior'), ('SR', 'Senior'), ('GR', 'Graduate'), ) type = models.CharField(max_length=2, choices=YEAR_IN_SCHOOL_CHOICES) With the code above I'm able to set the type with a value that doesn't appear in YEAR_IN_SCHOOL_CHOICES. I would like to restrict the field type with given list. Any idea ? |
|
|
Posted by Conley Owens ![]() |
|
|
Check out this link:
http://stackoverflow.com/questions/21454/specifying-a-mysql-enum-in-a-django-model You can't really do it in a djangoish way (without creating your own custom stuff as the answers suggest), and I would suggest that you just restrict it yourself in your views and forms. --- Last Edited by Conley Owens at 2009-10-23 16:45:54 --- |
|
|
Posted by rocjojo |
|
|
Hello,
I've already seen this stackoverflow post. I think i'm gonna make a model instead of Choices and check if it exists before saving. Thinks for your help Joel |



