[Answer]-Variable which is a database query doesnt render properly in template

1👍

There may not be any data in the database. Try this.

{% if table|length %}
    {% for key, value in table.items %}
        <p> {{ key }} : {{ value }}</p>
    {% endfor %}
{% else %}
    <div>There are no data in the database</div>
{% endif %} 

0👍

I was rendering the database values wrongly on the template , this is how it should be done for a list of dictionary

    {% for x in table %}
     {% for key,values in x.items %}
     <p> {{key}} : {{values}} </p>
     {% endfor %}
   {% endfor %}

Leave a comment