Answer the question
In order to leave comments, you need to log in
How to display footer data?
Good day! Stuck in one place. Header and footer on all pages of the site are the same, I created base.html. Connected it to the appropriate templates. Header got up without problems, everything is displayed, but footer (together with data) is correctly displayed only on the main page, and on the other two only html markup, without data (django).
Here is an example code footer, base.html
<!-- FOOTER -->
<footer>
<div class="wrapper cf">
<!-- widgets -->
<ul class="widget-cols cf">
<li class="first-col">
<div class="widget-block">
<h4>RECENT POSTS</h4>
{% for blog in blog_list|slice:":3" %}
<div class="recent-post cf">
<a href="#" class="thumb"><img src="{{ blog.image.url }}" alt="Post" width="35" height="35"/></a>
<div class="post-head">
<a href="#">{{ blog.title }}</a><span>{{ blog.publish_date }}</span>
</div>
</div>
{% endfor %}
</div>
</li>
<li class="third-col">
<div class="widget-block">
<div id="tweets" class="footer-col tweet">
<h4>TWITTER WIDGET</h4>
</div>
</div>
</li>
<li class="fourth-col">
<div class="widget-block">
<h4>CATEGORIES</h4>
<ul>
<li class="cat-item"><a href="#" >Design</a></li>
<li class="cat-item"><a href="#" >Photo</a></li>
<li class="cat-item"><a href="#" >Art</a></li>
<li class="cat-item"><a href="#" >Game</a></li>
<li class="cat-item"><a href="#" >Film</a></li>
<li class="cat-item"><a href="#" >TV</a></li>
</ul>
</div>
</li>
</ul>
<!-- ENDS widgets -->
<!-- bottom -->
<div class="footer-bottom">
<div class="left">by Candy<a href="#" >candy.art</a></div>
<ul id="social-bar" class="cf sb">
<li><a href="http://www.facebook.com" title="Become a fan" class="facebook">Facebook</a></li>
<li><a href="http://www.twitter.com" title="Follow my tweets" class="twitter"></a></li>
<li><a href="http://plus.google.com" title="Enter my circles" class="plus"></a></li>
</ul>
</div>
<!-- ENDS bottom -->
</div>
</footer>
<!-- ENDS FOOTER -->
class BaseListView(generic.ListView):
model = Article
context_object_name = 'blog_list'
template_name = 'base.html'
Answer the question
In order to leave comments, you need to log in
Perhaps it is worth understanding how the page is rendered, then all questions will go away.
As one of the solutions, this is middleware or a custom tag.
Hello everyone who looked. The answer for me was simple, thanks to alfss for the advice. Actually the answer is:
class BaseListView(generic.ListView):
model = Article
context_object_name = 'blog_list'
template_name = 'base.html'
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 blog list
context['blog_list'] = Article.objects.all() <— добавил в контекст данные для отображения
return context
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question