Previously, get_FIELD_display(), for a blank or unknown value of FIELD, return the value unchanged, e.g. say None or an empty string.
After the change, it returns the automatically inserted blank choice (-------). This is due to it now using field.flatchoices, which is dynamically generated through the get_choices() method, whereas it previously just used field.choices, which contains the unmodified tuple the field receives through init.
This may also be an unwanted discrepancy between the two attributes.
class Whiz(models.Model):
CHOICES = (
(1,'First'),
(0,'Other'),
)
c = models.IntegerField(choices=CHOICES, null=True)
>>> w = Whiz(c='')
>>> w.save()
>>> w.get_c_display()
u''
Expected:
u''
Got:
u'---------'
Reference:
http://groups.google.com/group/django-developers/browse_thread/thread/5b899cb2d8388717/50ed30aa358e2d59?hl=en#50ed30aa358e2d59