For instance, I have a field in a model class called Role, and instead of creating a separate Role model by hand, that I then later have to write code to populate with 5 known values, is there a way to express that the Role field in my Person model can only hold those 5 known values?
views:
28answers:
2
+2
Q:
Is there a way to create a field in Django so that it's constrained to be within a set of values?
+2
A:
Here is the documentation on choices. http://docs.djangoproject.com/en/1.2/ref/models/fields/#choices in the admin site they appear as drop down boxes automatically:).
Dean
Dean
2010-07-18 21:12:06