[Answer]-Django: get data in included template

1👍

This is exactly what inclusion tags are for.

0👍

As I understand you have your data in right_sidebar_news view?
You have to have your desired Entry objects in all templates that include _right_sidebar_news.html so that this Entry could be rendered.
I’d go in a class-based view:

class EntriesViewMixin(object):
    def get_context_data(self, **kwargs):
        context = super(EntriesViewMixin, self).get_context_data(**kwargs)
        context.update({'last_entry': Entry.objects.last()})
        return context

class SomeView(EntriesViewMixin, TemplateView):
    template_view = 'some_theme.html'

But I’m not sure if I understand the question correctly.
Hope that helped 🙂

👤McAbra

Leave a comment