def tags(request): """ =============================================================================== function: 标签管理 developer: BeginMan add-time 2013/12/28 =============================================================================== """ context = {} try: tag_list = Tags.objects.all().order_by('-add_time') cloud = tagsCloud() # 操作 if request.method == 'POST': name = request.POST.get('name') type = request.POST.get('type') id = request.POST.get('id',0) if Tags.objects.filter(name=name).exists(): # 如果存在该标签在返回提示 return HttpResponse('0') if type == '0': # create Tags.objects.create(name=name) elif type == '1': # 删除 Tags.objects.filter(pk=id).delete() else: # edit Tags.objects.filter(pk=id).update(name=name) return HttpResponse('1') except Exception,e: log.error('tags:%s' % e) return HttpResponse('err')
def sideInfo(): context = {} category = Category.objects.all() # 所有分类 blog = Blog.objects.filter(status__gt=0, password__isnull=False) newblog = blog.order_by("-add_time")[:15] # 最新前十条博客 hotblog = blog.order_by("-hit")[:15] # 最火前十条博客 cloud = tagsCloud() # 标签云 context["category"] = category context["newblog"] = newblog context["hotblog"] = hotblog context["cloud"] = cloud return context