[Answer]-Issues with Fetching the data from database

1πŸ‘

βœ…

.all() will return a list of objects that represent the rows in your model. .get() only returns one object. Your template is trying to print the result of all() if it was one object.

This is the same as if you had a list and you wanted to loop through it. In your view you would do:

product = Product_attributes.objects.all()
for i in product:
   print i.size
   print i.color

The equvalent for the template is:

<ul>
{% for i in product %}
   <li>{{ i.size }}</li>
   <li>{{ i.color }}</li>
{% endfor %}
</ul>
πŸ‘€Burhan Khalid

0πŸ‘

Although this question isn’t clear it seems like you are having a bit of problem with Field Lookups. It is fairly easy to learn Here is a link to get you started

πŸ‘€Frantz Romain

Leave a comment