0

我正在尝试向log in用户打印所有最新10 articlesnumber of commentsnumber of votes. 我views.py的那个函数是这样的:

article_query=Article.objects.filter(creator=user.id)
    article = Article.objects.all()
    latest_articles = article.order_by('-pub_date')
    return render_to_response('home.html', {'article_user': article_query, 'user_info':user_info, 'latest_articles':latest_articles}, RequestContext(request))

但是,我没有专门的部分作为vote_countcomment_count存储在数据库中。我只是将可能已投票或评论的用户存储在文本字段中,并ids用分号 ( ) 分隔。;例如。投票--> (2;4;6;)

如何输出模板中的投票数?我应该像在数据库中那样制作一个专用单元格,votes_count还是应该通过在视图文件中编写一些繁琐的函数然后显示它来实现这一点?拥有数百万用户的网站的常规方法是什么?

4

0 回答 0