Todd O'Bryan wrote: > I'm an almost complete Python newbie, and I found dictionaries, but > is there an automatic way to deal with lists of pairs that have been > used for choices settings in the admin view, cause they're tuples of > tuples, right? > > I have > > KINDS = ((0, 'foo'), (1, 'bar')) > > class Thing(meta.Model): > kind = meta.IntegerField(choices=KINDS) > > I'd like to include the text values of kind in the object's __repr__ > method and in a table view, but can't figure out how.
If you visit the Admin's documentation site (link in the top bar), under Models it will point you to the fact that Django magically creates a function for you to do just that. In your example this would be: something.get_kind_display() -- --Max Battcher-- http://www.worldmaker.net/ "I'm gonna win, trust in me / I have come to save this world / and in the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---