本文整理汇总了Python中blog.models.Category.icon_id方法的典型用法代码示例。如果您正苦于以下问题:Python Category.icon_id方法的具体用法?Python Category.icon_id怎么用?Python Category.icon_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Category
的用法示例。
在下文中一共展示了Category.icon_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from blog.models import Category [as 别名]
# 或者: from blog.models.Category import icon_id [as 别名]
def post(self):
from .models import FontIcon,FontIconLibrary
iconclass = None
i = request.form.get('icon',None)
if i is not None:
lib,icon = i.split('-')[0],i.split('-')[1:]
iconclass = FontIcon.query.filter(FontIcon.name==''.join(map(str,icon)),FontIconLibrary.name==lib).first()
self._context['form_args'] = {'heading':self._form_heading}
self._form = self._form(request.form)
if self._form.validate():
from blog.models import Category
c = Category.query.filter(Category.name==self._form.name.data).first()
if c is None:
c = Category()
if iconclass is not None:
c.icon_id = iconclass.id
c.name = self._form.name.data
c.description = self._form.description.data
c.save()
self.flash('You added category: {}'.format(c.name))
if request.args.get('last_url'):
return self.redirect(request.args.get('last_url'),raw=True)
else:
self.flash('There is already a category by that name, try again')
return self.redirect('core.index')