- Thread Author
- #1
I have an HTML table that I want to be populated from views.py. Here is my code:
index.html
views.py
The table doesn't get populated and I don't see any error code. Is it the format in pizza_data?
The reason why pizza_data is hardcoded is because that is a JSON file that I need to figure out how to insert but for now I want to see if the {% for %} loop can populate but it is not.
index.html
Code:
{% for pizza in pizza %}
<tr id="{{pizza.name}}">
{% for item in pizza.pizza.all %}
<td>{{item.status}}</td>
<td>{{item.name}}</td>
{% endfor %}
</tr>
{% endfor %}
views.py
Code:
def pizza(request):
pizza_data = [{'name': 'Pepperoni Pizza', 'status': 'Ready'}]
return render(request, "index.html", {'pizza': pizza_data})
The table doesn't get populated and I don't see any error code. Is it the format in pizza_data?
The reason why pizza_data is hardcoded is because that is a JSON file that I need to figure out how to insert but for now I want to see if the {% for %} loop can populate but it is not.