def blog_list(request): blogs_all_list = Blog.objects.all() context = get_blog_list_commom_data(request, blogs_all_list) context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() return render(request, 'blog_list.html', context)
def blogs_with_type(request, blog_type_pk): blog_type = get_object_or_404(BlogType, pk=blog_type_pk) blogs_all_list = Blog.objects.filter(blog_type=blog_type) context = get_blog_list_commom_data(request, blogs_all_list) context['blog_type'] = blog_type context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() return render(request, 'blogs_with_type.html', context)
def produce_detail(request, produce_pk): context = {} produce = Produce.objects.filter(pk=produce_pk) context['produce'] = produce[0] context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() context['produce_types_two'] = get_type_navigation_two() return render(request, 'produce_detail.html', context)
def home(request): homeimage = HomeImage.objects.all() context = {'hms': homeimage} context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() context['produce_types_two'] = get_type_navigation_two() return render(request, 'home.html', context)
def produce_list(request, produce_type_pk): produce_type = get_object_or_404(ProduceType, pk=produce_type_pk) produces_all_list = Produce.objects.filter(produce_type=produce_type) context = {} context['produces'] = produces_all_list context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() context['produce_types_two'] = get_type_navigation_two() return render(request, 'produce_list.html', context)
def blog_detail(request, blog_pk): blog = get_object_or_404(Blog, pk=blog_pk) #blog_content_type = ContentType.objects.get_for_model(blog) #comments = Comment.objects.filter(content_type=blog_content_type,object_id=blog.pk,parent=None) produces_all_list = Produce.objects.all() context = {} context['produces'] = produces_all_list context['blog'] = blog #context['user'] = request.user #context['comments'] = comments.order_by('-comment_time') #context['comment_form'] = CommentForm(initial={'content_type':blog_content_type.model,'object_id':blog_pk,'reply_comment_id':0}) context['previous_blog'] = Blog.objects.filter( created_time__gt=blog.created_time).last() context['next_blog'] = Blog.objects.filter( created_time__lt=blog.created_time).first() context['produce_types'] = get_type_navigation() context['blog_types'] = get_type_blog() context['programe_types'] = get_programe_navigation() response = render(request, 'blog_detail.html', context) #响应 return response