0

Hi guys I have a pretty basic question in a template of Django

In my view.py file I have this

select_list = [{'v':'By Visit'}, {'p':'by Patient'}]
select_item = {}
select_item['select_opc'] = select_list
final_value.append(select_item)
print final_value
context['new_object_list'] = final_value
return context

So in my view I have this

  {% for item in new_object_list  %}
    {% for lista in item.select_opc %}
      {{ lista }}
    {% endfor %}
  {% endfor %}

lista return this

{'v': 'By Visit'} {'p': 'by Patient'}

a dictionary I want to create a select with this but I only obtain de key, no the value

I try this

  {% for item in new_object_list  %}
    {% for lista in item.select_opc %}
      {% for k, v in lista %}
        {{ k }}
        {{ v }} or {{ lista.k }}
      {% endfor %}
    {% endfor %}
  {% endfor %} 

I try this too {% for k, v in lista.iteritems %} but nothing work, but if I try in the terminal works!!

Any idea

Stone
  • 749
  • 1
  • 11
  • 30
  • Thanks @anonymous but this option don't work for my I have a error in my html file if do this `{{ lista[k] }}` – Stone Oct 26 '16 at 15:03
  • I worked on it long back. Just took the reference. Try: `{% for k, v in lista.items %} {{k}} {{v}} {% endfor %}` – Moinuddin Quadri Oct 26 '16 at 15:05
  • thanks @anonymous but this option only show me the key (k), v es empty, I change the question .. I add the view part... – Stone Oct 26 '16 at 15:13

0 Answers0