Reputation: 161
I have a model field with choices. Like this:
CHAIN_CHOICES = (
('P','Public'),
('N','Private')
)
chain = models.CharField(max_length=1, choices=CHAIN_CHOICES, verbose_name=u"Chain")
In my template I would like to call it simillary to this:
<li><i class="glyphicon glyphicon-tags"></i> <span>{{mymodel.chain}}</span></li>
Problem is .... this is calling 'N' or 'P' and I would like to call the 'Public' - 'Private' values. Any hint would be wellcome.
Regards,
J.M.
Upvotes: 0
Views: 1480
Reputation: 423
@JanMejor
I want to call from templates to "choices" too but without duplicates. Here is a different way you did:
...
{% for i in mymodel %}
{{ i.chain }}
{% endfor %}
...
Still, it will show duplicates if you have couple posts with the same "choice value"
Upvotes: 0
Reputation: 161
Guess I have found my answer:
{{ mymodel.get_chain_display }}
Unless there is a different way ??
Upvotes: 4