Py学习  »  kola  »  全部回复
回复总数  1
  
  #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%}