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
- [Answer]-Tastypie Accessing Query Before Data Gets Replaced by Request
- [Answer]-Django: Check if user have added a new instance in the form?
- [Answer]-Django β Changing/Initializing a Form Field after Validation
- [Answer]-Django url pattern not registering
Source:stackexchange.com