Python django custom query result in html
<p>Just started  to learn python django framework ,i am trying to display a custom  query result in html page. </p>

<pre><code>def index(request):
    with connection.cursor() as cursor:
        cursor.execute("SELECT * FROM polls_post")
context ={
        'all_posts':cursor.fetchall()
    }
</code></pre>

<p>In my html page</p>

<pre><code>&lt;ul&gt;
        {%  for post in all_posts %}
            &lt;li&gt;{{ post }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
</code></pre>

<p>But it displays the value as tuples ,so how can i get query result with table column name such as i can print the values like this way</p>

<pre><code>&lt;ul&gt;
            {%  for post in all_posts %}
                &lt;li&gt;{{ post.title }}&lt;/li&gt;
                &lt;li&gt;{{ post.name }}&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;
</code></pre>