1👍
✅
The first thing is that you declare block ‘sidebarBlock’ in base.html but you don’t fill it with something neither in index.html nor in articlePage.html. It works in index.html because you send variable with your view. You cannot take any variables from your base.html. You should provide these in your ArticleView.
It should look like this:
class ArticleView(generic.DetailView):
model = Article
template_name = 'articles/articlePage.html'
def get_queryset(self):
self.latest_article_list = Article.objects.filter(
article_pub_date__lte=timezone.now()).order_by('-article_pub_date')[:4]
return Article.objects.filter(article_pub_date__lte=timezone.now())
def get_context_data(self, **kwargs):
context = super(ArticleView, self).get_context_data(**kwargs)
context['latest_article_list'] = self.latest_article_list
return context
Source:stackexchange.com