私信  •  关注

kola

kola 最近回复了
  
  #view
    def index(request):
        cate = Category.objects.all()
        return render(request,'index.html',locals())



 #index.html
{%for c in cate%}
    {{c.cate_name}}:{{c.article_set.all|length}}
    {%for Article in c.article_set.all%}
        {{Article.art_title}}
    {%endfor%}
{%endfor%}