On 1/16/06, Mike <[EMAIL PROTECTED]> wrote: > > How do I do that? To retrieve a field's choices from the model? > > class Person(meta.Model): > height = meta.CharField(maxlength=100, > choices=(('tall','Tall'),('short','Short'))) > > >>> Person.height.choices #????
In the magic removal branch, you are correct: Person.height.choices will give you the original list of tuples used at instantiation. If you want the list that is used for display purposes, try: >>> Person.height.get_choices() This will include "-------" (Undefined) in the list of choices returned. There are some optional parameterrs on this method if you need to customize the output; see core/db/models/fields/__init__.py for details. In v0.90, v0.91 or trunk, you need to go through the meta object associated with the model class to get to the Field object that stores the choices: >>> Person._meta.get_field('height').choices >>> Person._meta.get_field('height').get_choices() Yours, Russ Magee