问题描述:

I have this in my model:

BEHV = (

('E', 'Externalizer'),

('I', 'Internalizer'),

)

# E or I ?

behavior_type = models.CharField(max_length=1, choices=BEHV)

And this in my template:

{{ s.behavior_type }}

Which renders

E

But I want it to render,

Externalizer

Instead. Is there I way to do this without swapping the tuples around in BEHV?

网友答案:

Just do this:

{{ s.get_behavior_type_display }}
相关阅读:
Top