ดึงข้อมูลรายการบล็อกด้วยธีมบูตสแตรปที่กำหนดเองและชั้นลอย

ฉันยังใหม่กับชั้นลอย ฉันจัดการเพื่อติดตั้งธีมบูตสแตรปแบบกำหนดเองของฉัน เพียงแค่คัดลอกเทมเพลตและไฟล์คงที่ในโฟลเดอร์ญาติในแอป django ของฉัน

สมมติว่าใน index.html ของฉันฉันมีรายการบล็อกเช่นนี้

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

ฉันจะดึงข้อมูลบล็อกของฉันที่เคยแทรกไว้ในหน้าผู้ดูแลระบบได้อย่างไร

ขอบคุณ


person user2697881    schedule 01.09.2013    source แหล่งที่มา


คำตอบ (1)


ที่ด้านบนของเทมเพลตของคุณให้ใส่:

{% load blog_tags %}

ทุกที่ที่คุณต้องการให้โพสต์บนบล็อกปรากฏขึ้นให้ทำดังนี้

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

ปลั๊กไร้ยางอาย: ฉันกำลังเขียนชุดบล็อกโพสต์ที่อธิบายกระบวนการสร้างธีมสำหรับ Mezzanine ลองเข้าไปดู http://bitofpixels.com/blog/mezzatheming-creating-mezzanine-themes-part-1-basehtml/

person joshcartme    schedule 18.09.2013