本文整理汇总了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()
示例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");
示例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'}))
示例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])
示例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, " "
示例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