Answers for "get context data django using template"

1

get context data django

class PublisherDetail(DetailView):

    model = Publisher

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super().get_context_data(**kwargs)
        # Add in a QuerySet of all the books
        context['book_list'] = Book.objects.all()
        return context
Posted by: Guest on July-09-2020
0

pass context data with templateview in django

class AboutView(TemplateView):
    template_name = 'about.html'

    def get_context_data(self, **kwargs):
        context = super(AboutView, self).get_context_data(**kwargs)
        context['dahl_books'] = Books.objects.filter(author="Dahl")
		return context
Posted by: Guest on September-22-2021

Code answers related to "get context data django using template"

Python Answers by Framework

Browse Popular Code Answers by Language