Just started to learn python django framework ,i am trying to display a custom query result in html page.
def index(request):
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM polls_post")
context ={
'all_posts':cursor.fetchall()
}
In my html page
<ul>
{% for post in all_posts %}
<li>{{ post }}</li>
{% endfor %}
</ul>
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
<ul>
{% for post in all_posts %}
<li>{{ post.title }}</li>
<li>{{ post.name }}</li>
{% endfor %}
</ul>