本文整理汇总了Python中blog.models.Category.desc方法的典型用法代码示例。如果您正苦于以下问题:Python Category.desc方法的具体用法?Python Category.desc怎么用?Python Category.desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Category
的用法示例。
在下文中一共展示了Category.desc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addCategory
# 需要导入模块: from blog.models import Category [as 别名]
# 或者: from blog.models.Category import desc [as 别名]
def addCategory(request):
name = request.POST['name']
slug = request.POST['slug']
desc = request.POST['desc']
type = request.POST['type']
pid = request.POST['category_parent']
if pid == '0':
pid = None
if type and type == 'add':
try:
cats=Category.objects.filter(name=name)
if cats.count() >= 1:
messages.add_message(request,messages.INFO,'categry [%s] already exits!'%(name))
else:
cat = Category(name=name,slug=slug,desc=desc,parent_id=pid)
cat.save()
messages.add_message(request,messages.INFO,'categry [%s] save ok!'%(name))
except Exception as e:
print 'exception:',e
elif type and type == 'edit':
id = request.POST.get('id','')
cat = Category.objects.get(id=id)
cat.name=name
cat.slug=slug
cat.desc=desc
cat.parent_id = pid
cat.save()
return HttpResponseRedirect('/admin/categories')
示例2: addCategory
# 需要导入模块: from blog.models import Category [as 别名]
# 或者: from blog.models.Category import desc [as 别名]
def addCategory(request):
if request.method=='POST':
name = request.POST['name']
slug = request.POST['slug']
desc = request.POST['desc']
type = request.POST['type']
if type and type == 'add':
try:
cats=Category.objects.filter(name=name)
if cats.count() >= 1:
messages.add_message(request,messages.INFO,'categry [%s] already exits!'%(name))
else:
cat = Category(name=name,slug=slug,desc=desc)
cat.save()
messages.add_message(request,messages.INFO,'categry [%s] save ok!'%(name))
except:
pass
elif type and type == 'edit':
id = request.POST.get('id','')
cat = Category.objects.get(id=id)
cat.name=name
cat.slug=slug
cat.desc=desc
cat.save()
return HttpResponseRedirect('/admin/categories')