[Answered ]-How to show in Django queryset dict-key and -values seperately in template?

1👍

Update template with below code:

            {{ test }}   <!--  test is list of dictonaries --> 
            <br>
            {% for item in test %} <!-- Loop to get each item(sub dictonary) from list-->
                <br>
                     {% for key,value in item.items %} <!-- Getting key values pairs from each sub dictonary item --> 
                        {% if forloop.last %} <!-- Checking if last iteration of loop just to add "::" after each value --> 
                            {{ value }} <!-- only displying values not keys from each sub dictionary -->
                        {%else%}
                            {{value }} , 
                        {% endif %}
                    {% endfor %}
                  
            {% endfor %}
        
    
    

Refer to this answer for removing decimal from result.
Django: remove Decimal prefix from queryset annotated field, when requesting values

0👍

Try fetching both the key and the value from the dictionary in the loop:

{% for key, value in test.items %}
<tr> 
    <td>{{ key }}</td>   
    <td>{{ value }}</td>
</tr>
{% endfor %}

If you want to format Decimal value see docs

Leave a comment