问题描述
我使用 django-mptt 作为类别模型。我想在屏幕截图中显示类别和子类别以及面包屑的列表
ex.com/men's/t-shirt/design
def home(request):
all_posts = Post.newmanager.all()
return render(request,'blog/index.html',{'posts': all_posts,'Category': Category.objects.all()})
def post_single(request,post):
post = get_object_or_404(Post,slug=post,status='published')
return render(request,'blog/single.html',{'post': post,'Category': Category.objects.all()})
{% load mptt_tags %}
<ul>
{% recursetree Category %}
<li>
{{ node.name }}
{% if not node.is_leaf_node %}
<ul class="children">
{{ children }}
</ul>
{% endif %}
</li>
{% endrecursetree %}
</ul>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)