当前位置: 首页>>代码示例>>Python>>正文


Python Tag.title方法代码示例

本文整理汇总了Python中models.Tag.title方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.title方法的具体用法?Python Tag.title怎么用?Python Tag.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Tag的用法示例。


在下文中一共展示了Tag.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_main

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import title [as 别名]
def show_main(request):
    if request.method == 'GET':
        template = 'tags/main.html'
        tags = Tag.objects.filter(user=request.user).order_by('-update_date')
        return common_django.render(request, template, {'tags': tags})
    else:
        tag = request.POST['tag'] if request.POST.has_key('tag') else None
        if tag:
            new_tag = Tag()
            new_tag.user = request.user
            new_tag.title = tag
            new_tag.save()
            return HttpResponseRedirect('/tags')
        else:
            return HttpResponseRedirect('/tags')
开发者ID:yamadentanaka,项目名称:veda,代码行数:17,代码来源:views.py

示例2: save_model

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import title [as 别名]
 def save_model(self, request, obj, form, change):
     obj.user = request.user
     obj.tags = obj.tags.lower()
     obj.save()
     obj.tags_list.clear()
     list = [k.strip() for k in obj.tags.split(',')]
     for t in list:
             tag = Tag.objects.filter(title=t)
             if not tag:
                 tag = Tag()
                 tag.title = t
                 tag.save()
                 obj.tags_list.add(tag)
             else:
                 obj.tags_list.add(tag[0])
     obj.save()
开发者ID:bbeestudio,项目名称:lemblog,代码行数:18,代码来源:admin.py

示例3: create_tags

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import title [as 别名]
 def create_tags(self, tags, post_id):
     post_tags = ''
     if tags is str:
         tags = tags.split(',')
     tags = set(tags)
     for tag in tags:
         tag = tag.strip()
         if not tag:
             continue
         the_tag = self.get_tag_by_title(tag)
         if not the_tag:
             the_tag = Tag()
             the_tag.title = tag
             the_tag.slug = tag
             the_tag.post_count = 1
             db.session.add(the_tag)
             db.session.commit()
         else:
             the_tag.post_count += 1
         if not the_tag.post_ids:
             the_tag.post_ids = '%s' % post_id
         else:
             ids = the_tag.post_ids.split('|')
             ids.append(str(post_id))
             ids = list(set(ids))
             the_tag.post_ids = '|'.join(ids)
         db.session.add(the_tag)
         if post_tags == '':
             post_tags = '%s' % the_tag.id
         else:
             ids = post_tags.split('|')
             ids.append(str(the_tag.id))
             ids = list(set(ids))
             post_tags = '|'.join(ids)
     db.session.commit()
     return post_tags
开发者ID:xiaojunchan,项目名称:YaBlog,代码行数:38,代码来源:mixin.py

示例4: post

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import title [as 别名]
    def post(self):
        json = {}
        if not self.current_user:
            json = {
                'error': 1,
                'msg': self._('Access denied')
            }
            self.write(json)
            return

        title = self.get_argument('title', None)
        slug = self.get_argument('slug', None)
        # valid arguments
        if not title:
            json = {
                'error': 1,
                'msg': self._('Title field can not be empty')
            }
            self.write(json)
            return
        elif self.get_tag_by_title(title):
            json = {
                'error': 1,
                'msg': self._('Tag already exists')
            }
            self.write(json)
            return
        if not slug:
            json = {
                'error': 1,
                'msg': self._('Slug field can not be empty')
            }
            self.write(json)
            return
        elif self.get_tag_by_slug(slug):
            json = {
                'error': 1,
                'msg': self._('Slug already exists')
            }
            self.write(json)
            return
        # create tag
        tag = Tag()
        tag.title = title
        tag.slug = slug
        self.db.add(tag)
        self.db.commit()
        # delete cache
        keys = ['TagCloud', 'SystemStatus']
        self.cache.delete_multi(keys)

        json = {
            'error': 0,
            'msg': self._('Successfully created'),
            'tag': {
                'id': tag.id,
                'title': tag.title,
                'slug': tag.slug,
                'permalink': tag.permalink,
                'post_count': tag.post_count
            }
        }
        self.write(json)
开发者ID:messense,项目名称:YaBlog,代码行数:65,代码来源:api.py


注:本文中的models.Tag.title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。