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


Python Tag.name方法代码示例

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


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

示例1: create_tags

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
def create_tags():
    names = [u"news", u"article", u"interview", u"test", u"review", u"témoignage"]
    for name in names:
        tag = Tag()
        name = LocalizedString(value=name, lang=u"fr")
        tag.name = name
        db.session.add(tag)
        db.session.commit()
开发者ID:alexpirine,项目名称:shelf-cms,代码行数:10,代码来源:manage.py

示例2: add_tag

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
def add_tag(request):
	var = request.POST
	is_title = bool(int(var['is_title']))
	new_tag=Tag()
	new_tag.name = var['tag_name']
	new_tag.description = var['tag_description']
	new_tag.is_title = is_title
	new_tag.save()
	return HttpResponse("ok");
开发者ID:zhangwentao,项目名称:accountbook,代码行数:11,代码来源:views.py

示例3: tag_add

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
def tag_add(request):
    t = Tag()
    t.x = float(request.GET['x'])
    t.y = float(request.GET['y'])
    t.z = float(request.GET['z'])
    t.name = request.GET['name']
    t.description = request.GET['description']
    t.save()
    return HttpResponse(json.dumps({'message': 'ok'}))
开发者ID:zidarsk8,项目名称:Fri,代码行数:11,代码来源:views.py

示例4: post_create_user

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
def post_create_user(sender, instance, created, **kwargs):
    print "Post save emited for", instance
    users = User.objects.filter(username="user_template")
    if created and len(users) > 0:
        user_template = users[0]
        print "user_template", user_template
        user = instance
        image_types = ImageType.objects.filter(user=user_template)
        print "image_types", image_types
        print 'mkdir {0}{1}'.format(BASE_DIR+'/segment/static/uploads/',str(user_template.id),str(user.id))
        os.popen('cp -a {0}{1} {0}{2}'.format(BASE_DIR+'/segment/static/uploads/',str(user_template.id),str(user.id)))
        for image_type in image_types:
            print "imagetype", image_type
            #folder_random_name = get_random_name()
            #print 'mkdir {0}{1}/{2}'.format(BASE_DIR+'/segment/static/uploads/',str(user.id),folder_random_name)
            #os.popen('mkdir {0}{1}/{2}'.format(BASE_DIR+'/segment/static/uploads/',str(user.id),folder_random_name))
            #os.popen('mkdir {0}{1}/{2}/segments'.format(BASE_DIR+'/segment/static/uploads/',str(user.id),folder_random_name))
            #os.popen('mkdir {0}{1}/{2}/segments'.format(BASE_DIR+'/segment/static/uploads/',str(user.id),folder_random_name))
            it = ImageType()
            it.name=image_type.name
            it.user = user
            it.folder = image_type.folder
            it.save()
            it.users_shared.add(user)
            tags = Tag.objects.filter(image_type=image_type)
            for tag in tags:
                t = Tag()
                t.name = tag.name
                t.image_type = it
                t.save()
            images = Image.objects.filter(image_type=image_type)
            print "images", images
            for image in images:
                i = Image()
                i.name = image.name
                i.image_type = it
                i.filename = str(image.filename).replace('/'+str(user_template.id)+'/','/'+str(user.id)+'/')
                #print 'cp "{0}{1}" "{2}{3}"'.format(BASE_DIR+'/segment/static/',str(image.filename),BASE_DIR+'/segment/static/' ,str(i.filename))
                #os.popen('cp "{0}{1}" "{2}{3}"'.format(BASE_DIR+'/segment/static/',str(image.filename),BASE_DIR+'/segment/static/' ,str(i.filename)))
                i.parent_segment = image.parent_segment
                i.save()
                segments = Segment.objects.filter(image=image)
                print "image id", image.id, "segments", len(segments), segments
                for segment in segments:
                    s = Segment()
                    s.x1 = segment.x1
                    s.y1 = segment.y1
                    s.x2 = segment.x2
                    s.y2 = segment.y2
                    s.image = i
                    s.filename = str(segment.filename).replace('/'+str(user_template.id)+'/','/'+str(user.id)+'/')
                    #print 'cp "{0}{1}" "{2}{3}"'.format(BASE_DIR+'/segment/static/',str(segment.filename),BASE_DIR+'/segment/static/',str(s.filename))
                    #os.popen('cp "{0}{1}" "{2}{3}"'.format(BASE_DIR+'/segment/static/',str(segment.filename),BASE_DIR+'/segment/static/',str(s.filename)))
                    s.save()
                    for tag in segment.tags.all():
                        tag_new = Tag.objects.filter(image_type=it,name=tag.name)
                        s.tags.add(tag_new[0])
开发者ID:tonibagur,项目名称:segment,代码行数:59,代码来源:views.py

示例5: find_or_add_tag

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
def find_or_add_tag(session, id, name):
    try:
        # Does the tag ID exist already?
        tag = session.query(Tag).filter_by(id=id).first()

        # If not, create it
        if tag == None:
            tag = Tag(id=id, name=name)
            session.add(tag)
            session.commit()
            return tag

        # If so, update the tag's name to latest data, then return it
        else:
            if name:
                if tag.name != name:
                    tag.name = name
                    session.commit()
            return session.query(Tag).filter_by(id=id).first()
    except:
        traceback.print_exc(file=sys.stderr)
        print >> sys.stderr, " "
开发者ID:thenoviceoof,项目名称:habitFetch,代码行数:24,代码来源:habitFetch.py

示例6: save

# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import name [as 别名]
 def save(self):
     t = Tag()
     t.name = self.cleaned_data['name']
     t.save()
     return t
开发者ID:jagadeeshe,项目名称:learndutch,代码行数:7,代码来源:forms.py


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