On Monday, May 21, 2012 9:39:59 AM UTC-4, Jon Clements wrote:
> > def experience_text(self):
> > return dict(CHOICES).get("self.level", "???")
> Haven't used django in a while, but doesn't the model provide a
> get_experience_display() method which you could use...
Duh, I totally missed seeing that! Yeah, that's exactly what I want. Thanks.
Hmmm, looking at the source, I see they went the dict().get() route:
def _get_FIELD_display(self, field):
value = getattr(self, field.attname)
return force_unicode(dict(field.flatchoices).get(value, value),
strings_only=True)
--
http://mail.python.org/mailman/listinfo/python-list