6. Dynamically exhibiting text data
from .models import *def store(request):
products = Product.objects.all() #? grabbing all products from the database (queryset)
context = {"products" : products}
return render(request, 'store.html', context) {% for product in products %}
{% endfor %}
{% if 'condition' %}
{% else %}
{% endif %}
<% for product in products %>
<p>Product: {{ product.name }}</p> <!-- Originally, what will be displayed in product is what is returned in its respective __str__ function on the models file-->
<p>Price: {{ product.price }}</p>
<% endfor %>
Last updated