Fetch blog entries with bootstrap custom theme and mezzanine

独自空忆成欢 提交于 2019-12-11 04:58:43

问题


I'm new to mezzanine, I managed to install my custom bootstrap theme just copying templates and static files in the relatives folders in my django app.

Assume in my index.html I have some blog entries like these

<h2>Other Entries</h2>
<article>
<h3>Blog Post 1</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>
<article>
<h3>Blog Post 2</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>
<article>
<h3>Blog Post 3</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>

How can I fetch my blog entries I've previously inserted in the admin page?

Thanks


回答1:


At the top of your template put:

{% load blog_tags %}

Then wherever you want the blog posts to show up put something like the following

{% blog_recent_posts as recent_posts %}
{% for blog_post in recent_posts %}
<h3>{{ blog_post.title }}</h3>
{{ blog_post.description_from_content|truncatewords_html:10|safe }}
<a href="{{ blog_post.get_absolute_url }}">Read more</a>
</article>
{% endfor %}

Shameless plug: I'm in the middle of writing a series of blog posts that describes the process of how I create themes for Mezzanine. Check it out, http://bitofpixels.com/blog/mezzatheming-creating-mezzanine-themes-part-1-basehtml/



来源:https://stackoverflow.com/questions/18561071/fetch-blog-entries-with-bootstrap-custom-theme-and-mezzanine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!