my views.py
from django.shortcuts import render, HttpResponse,redirect
from .models import *
# Create your views here.
def index(request):
products=Product.objects.all()
params={'product':products}
categories=Category.objects.all()
category={'category':categories}
return render(request,'index.html',params,category)
i am creating an ecommerce website on django and i want to pass two context in index.html one is product and one is category but after doing this the index.html is not working
2
Answers
You can put two items inside a dictionary. Instead of
You can do this:
And then pass the context dict:
You merge the two dictionaries, so: