I have two tables, in the example (any) of the figure below
I have the Paises
table and the Energia
table
SettingupathirdtableinDjangoIwouldhavesomethingwiththefields
pais,energia,valorÁustria,Carvão,3.6Áustria,Ciclocombinadodegás,3.4
andsoon.
Question:HowwouldImountthistableinthetemplateasitisintheimage?
Edited:
@mgibsonbrI'veadaptedtomytemplate,seethecodebelow.
defquotation_list(request):stores=list(Store.objects.all())products=list(Product.objects.all())#indiceindex_store={store.id:indexforindex,storeinenumerate(stores)}index_product={product.id:indexforindex,productinenumerate(products)}#dadosparaotemplatecabecalho=["Lojas"] + [store.store for store in stores]
linhas = [([product.product] + [None for store in stores])
for product in products]
for pev in Quotation.objects.all():
linhas[index_store[pev.store_id]][
index_product[pev.product_id]] = pev.price
But gave the following error.
Alias, how do I return the items in context to render on the page? The return
was missing.