Issue
I'm stuck on this error I am a new user of Django I am following the steps correctly and learning through YT.
When I run python manage.py runserver the HTML shows
My index.html file
<!DOCTYPE html>
<header>
CRUD Operation with PostgreSQL
</header>
<body>
<center>
<h1>How to create CURD Ops with PostgreSQL</h1>
<h3>Learning Django and CURD</h3>
<hr/>
<table border = "1">
<tr>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Email</th>
<th>Occupation</th>
<th>Salary</th>
<th>Gender</th>
</tr>
{% for results in data% }
<tr>
<td>{{result.id}}</td>
<td>{{result.name}}</td>
<td>{{result.email}}</td>
<td>{{result.occupation}}</td>
<td>{{result.salary}}</td>
<td>{{result.gender}}</td>
</tr>
{% endfor %}
</table>
</center>
</body>
I tried to change endfor to endblock nothing works. I don't know how to solve this, Please help.
Solution
Look at your code here:
{% for results in data% }
<tr>
<td>{{result.id}}</td>
<td>{{result.name}}</td>
<td>{{result.email}}</td>
<td>{{result.occupation}}</td>
<td>{{result.salary}}</td>
<td>{{result.gender}}</td>
</tr>
{% endfor %}
You need to change {% for results in data% }
to {% for result in data %}
. Be careful, where you put whitespaces and look at plural results
in for loop, when you actually uses singular result
inside it.
Answered By - NixonSparrow
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.