标签:rar for html 分享图片 lis strong png nbsp creat
# 文章详情页 re_path(r‘^(?P<username>\w+)/articles/(?P<article_id>\d+)$‘, views.article_detail, name=‘article_detail‘),
def article_detail(request, username, article_id): """文章详情页""" user_obj = models.UserInfo.objects.filter(username=username).first() blog = user_obj.blog # 查询当前站点对象 article_list = models.Article.objects.filter(user=user_obj) cate_list = models.Category.objects.filter(blog=blog).values(‘pk‘).annotate(c=Count("article__title")).values_list("title", ‘c‘) tag_list = models.Tag.objects.filter(blog=blog).values(‘pk‘).annotate(c=Count(‘article‘)).values_list(‘title‘,‘c‘) date_list = models.Article.objects.filter(user=user_obj).extra(select={‘y_m_date‘:"date_format(create_time,‘%%Y-%%m‘)"}).values(‘y_m_date‘).annotate(c=Count(‘nid‘)).values_list(‘y_m_date‘, ‘c‘) return render(request,‘blog/article_detail.html‘,{"username":username,‘blog‘:blog,‘article_list‘:article_list,"tag_list":tag_list,"date_list":date_list, "cate_list":cate_list})
# -*- coding: utf-8 -*- # @Time : 2018/08/04 0004 22:03 # @Author : Venicid from django import template from django.db.models import Count from blog import models register = template.Library() @register.simple_tag def multi_tag(x,y): return x*y @register.inclusion_tag("blog/classification.html") def get_classification_style(username): user_obj = models.UserInfo.objects.filter(username=username).first() blog = user_obj.blog cate_list = models.Category.objects.filter(blog=blog).values(‘pk‘).annotate(c=Count("article__title")).values_list("title", ‘c‘) tag_list = models.Tag.objects.filter(blog=blog).values(‘pk‘).annotate(c=Count(‘article‘)).values_list(‘title‘,‘c‘) date_list = models.Article.objects.filter(user=user_obj).extra(select={‘y_m_date‘:"date_format(create_time,‘%%Y-%%m‘)"}).values(‘y_m_date‘).annotate(c=Count(‘nid‘)).values_list(‘y_m_date‘, ‘c‘) return {‘blog‘:blog,"tag_list":tag_list,"date_list":date_list, "cate_list":cate_list}
def article_detail(request, username, article_id): """文章详情页""" user_obj = models.UserInfo.objects.filter(username=username).first() blog = user_obj.blog # article_id对应的文章 article_obj = models.Article.objects.filter(pk=article_id).first() return render(request,‘blog/article_detail.html‘,locals())
4
5
6
7
8
9
标签:rar for html 分享图片 lis strong png nbsp creat
原文地址:https://www.cnblogs.com/venicid/p/9420513.html