Let's say my sql table looks like this..
products table
--------------------------------
| id | Model| Manufacturer |
--------------------------------
| 1 | ABC | Samsung |
| 2 | XYZ | LG |
| 3 | ZYX | Sony |
--------------------------------
in django view i fetched all records from this table and passed it to template..
def compare(request):
product_ids = request.GET.get('product_ids')
products = Product.objects.filter(id__in=product_ids)
return render(request, 'compare.html', {'products': products})
as query_set result records comes like one after the other we can say it is following row wise but for this case in template i wanted to create an html table and the result should come like this ..
--------------------------------------------
|id | 1 | 2 | 3 |
|Model | ABC | XYZ | ZYX |
|Manufacturer | Samsung | LG | Sony |
--------------------------------------------
By looking at above example you can see data is rendered as column wise.
so please suggest me a better method in Django by which i can achieve this and also please correct me if i'm wrong as i'm beginner in Django.
Thanks in advance