我不能像 wordpress 那样创建 Categories 子类别

问题描述

我使用 django-mptt 作为类别模型。我想在屏幕截图中显示类别和子类别以及面包屑的列表

ex.com/men's/t-shirt/design

Breadcrumb

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...