Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to pass two dictionaries but only first one works

Tags:

django

views.py:

def home(request):
    return render(request, 'blog/home.html', {'title': 'HOME'}, {'post': posts})

In this code, only title works. when I took {'post': posts} before {'title': 'HOME'} , post works but title don't. I have to use both in templates. I'm a beginner in django. How can i fix this problem ?

like image 287
dipak Avatar asked Dec 05 '25 17:12

dipak


1 Answers

You can only have one context dictionary, but a dictionary can have as many key/values as you want.

 def home(request):
      context = {'title': 'HOME','post': posts}
      return render(request, 'blog/home.html',context)
like image 155
arjun Avatar answered Dec 07 '25 14:12

arjun