WISAM
WISAM

Reputation: 1920

django generic view send context to multiple templates at the same time

I am trying to send the listview context (book_list) in this case to more than one template at the same time.

I have tried to edit templates_names by doing this:

class BookListView(ListView):
    model = Book
    def get_template_names(self):
        template_name=["catalog/index.html","catalog/book_list.html"]
        return template_name

but book_list is still only known to catalog/book_list.html not to catalog/index.html(so the function I have added did NOT do anything).

any suggestions please?

Best regards

Upvotes: 1

Views: 443

Answers (2)

이신후
이신후

Reputation: 11

render multiple template from a single view in django

I had same problem. If you send arguments to parents html and if your htmls are children. They can access to arguments. check the link.

Upvotes: 1

pythad
pythad

Reputation: 4267

You just cannot :) Each view is responsible for one url and one template in will render. Actually I cannot even find and example when one would need to do what you're trying to do.

I think you have to read about template inheritance

Upvotes: 1

Related Questions