Ambil entri blog dengan tema khusus bootstrap dan mezzanine

Saya baru mengenal mezzanine, saya berhasil menginstal tema bootstrap khusus saya hanya dengan menyalin templat dan file statis di folder kerabat di aplikasi Django saya.

Asumsikan di index.html saya, saya memiliki beberapa entri blog seperti ini

<h2>Other Entries</h2>
<article>
<h3>Blog Post 1</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="/id#">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="/id#">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="/id#">Read more</a></p>
</article>

Bagaimana cara mengambil entri blog yang sebelumnya saya sisipkan di halaman admin?

Terima kasih


person user2697881    schedule 01.09.2013    source sumber


Jawaban (1)


Di bagian atas templat Anda, letakkan:

{% load blog_tags %}

Lalu dimanapun Anda ingin postingan blog tersebut muncul, letakkan sesuatu seperti berikut

{% 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="/id{{ blog_post.get_absolute_url }}">Read more</a>
</article>
{% endfor %}

Steker yang tidak tahu malu: Saya sedang menulis serangkaian postingan blog yang menjelaskan proses cara saya membuat tema untuk Mezzanine. Coba lihat, http://bitofpixels.com/blog/mezzatheming-creating-mezzanine-themes-part-1-basehtml/

person joshcartme    schedule 18.09.2013