0
I wanted to turn the following list into a dictionary:
lists py.
status_list = (
('c', 'cancelado'),
('elab', 'em elaboração'),
('p', 'pendente'),
('co', 'concluido'),
('a', 'aprovado')
)
So I did the following:
Views.py
class ProposalList(ListView):
template_name = 'core/proposal/proposal_list.html'
model = Proposal
paginate_by = 10
def get_context_data(self, **kwargs):
context = super(ProposalList, self).get_context_data(**kwargs)
dct = {}
for i in status_list:
dct[i[0]] = i[1]
context['status'] = dct
return context
And a dictionary returns to me:
{'p': 'pendente', 'co': 'concluido', 'elab': 'em elaboração', 'a': 'aprovado', 'c': 'cancelado'}
Dai no template I wanted to make:
<ul class="list-inline">
{% for item in status %}
<li name="{{ item }}">{{ get_item_display }}</li>
{% endfor %}
</ul>
Question: Why doesn’t it work? In this case, get_item_display returns nothing.