我正在處理一個包含標記。在超級外殼中,標籤返回適當的數據集nevertheles,我沒有看到包含模板在調用模板上呈現。我只能猜測包含模板位於錯誤的位置。截至目前,模板位於TEMPRATE_DIRS中的唯一文件夾MYPROJECT/templates。請幫我弄清楚我在這裏做錯了什麼。 TIA!django包含標記不呈現
MYPROJECT /編輯部/ templatetags/blog_extras.py - >http://pastebin.com/ssuLuVUq
from mezzanine.blog.models import BlogPost
from django import template
register = template.Library()
@register.inclusion_tag('featured_posts.html')
def featured_posts_list():
"""
Return a set of blog posts whose featured_post=True.
"""
blog_posts = BlogPost.objects.published().select_related("user")
blog_posts = blog_posts.filter(featured_post=True)
# import pdb; pdb.set_trace()
return {'featured_posts_list': blog_posts}
MYPROJECT /模板/ featured_posts.html - >http://pastebin.com/svyveqq3
{% load blog_tags keyword_tags i18n future %}
Meant to be the the infamous "Featured Posts" Section!
{{ featured_posts_list.count }}
<ul>
{% for featured_post in featured_posts_list %}
<li> {{ featured_post.title }} </li>
{% endfor %}
</ul>
MYPROJECT/settings.py - > pastebin.com/Ed53qp5z
MYPROJECT/templates/blog/blog_post_list.html - > pastebin.com/tJedXjnT
嘗試改變> {%負載blog_tags keyword_tags未來的i18n%} 這個> {%負載blog_extras keyword_tags未來的i18n%} –