Thank you for reading.
Even though data is stored in the Product, it is not output to the store.html screen. What might be the problem? I checked Product is saved with admin page.
I'm so new I have no idea what I'm doing wrong. Thank you very much.
views.py
def store(request):
global products, context
data = cartData(request)
cartItems = data['cartItems']
products = Product.objects.all()
context = {'products': products, 'cartItems': cartItems}
return render(request, 'maps/store.html', context)
models.py
class Product(models.Model):
poiid = models.DecimalField(max_digits=7, decimal_places=2)
name = models.CharField(max_length=200, null=True)
price = models.CharField(max_length=7, null=True)
address = models.CharField(max_length=7, null=True)
digital = models.BooleanField(default=False, null=True, blank=True)
def save(self, *args, **kwargs):
super().save(*args, **kwargs) # Call the "real" save() method.
def __str__(self):
return self.name
# url = ''
# return url
store.html
{% extends 'maps/main.html' %}
{% load static %}
{% block content %}
<div class="row">
<div class="col-md">
<div class="card card-body">
<table class="table table-sm">
<tr>
<th>poiid</th>
<th>name</th>
<th>category</th>
<th>address</th>
<th>save</th>
</tr>
{% for product in products %}
<tr>
<td>{{product.poiid}}</td>
<td>{{product.name}}</td>
<td>{{product.price}}</td>
<td>{{product.address}}</td>
<td><button data-product={{product.id}} data-action='add' class="btn btn-outline-secondary add-btn update-cart">save</button></td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock content %}