本文整理汇总了Python中photologue.models.Photo.tags方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.tags方法的具体用法?Python Photo.tags怎么用?Python Photo.tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photologue.models.Photo
的用法示例。
在下文中一共展示了Photo.tags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadUrlImage
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import tags [as 别名]
def loadUrlImage(url='', title='', tags='', format='jpg', slug=''):
""" """
if not url:
url = 'http://irudiak.argazkiak.org/1d3023545b4051907e533648e66329f8_c.jpg'
title = 'Kakalardoa'
tags = 'test argazkiak'
if not slug:
slug = time_slug()
if Photo.objects.filter(slug=slug):
slug = time_slug_long()
title = title[:99]
if Photo.objects.filter(title=title):
title = '%s %s' % (slug, title)[:90]
image = _getUrlImage(url)
if not image:
return None
photo = Photo()
photo.title = title[:100]
photo.tags = tags
photo.slug = slug
try:
image_t = Image.open(ContentFile(image.read()))
image_t = image_t.convert("RGB")
f=StringIO()
image_t.save(f,"JPEG")
f.seek(0)
photo.image.save('%s.%s' % (slug,format), ContentFile(f.read()))
except Exception, e:
print 'Errorea irudi honekin RGB', photo.slug, e
return photo
示例2: loadUrlImage
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import tags [as 别名]
def loadUrlImage(url='', title='', tags='', format='jpg'):
""" """
if not url:
url = 'http://ahotsak.com/files/Proiektuak/beasain.jpg'
title = 'Beasain'
tags = 'proiektua beasain'
slug = slugify(title)[:50]
image = _getUrlImage(url)
if not image:
return 0
if Photo.objects.filter(title_slug=slug):
for i in range(1,1000):
new_slug = '%s-%d' % (slug,i)
new_title = '%s (%d)' % (title,i)
if not Photo.objects.filter(title_slug=new_slug):
slug = new_slug
title = new_title
break
photo = Photo()
photo.title = title
photo.tags = tags
photo.title_slug = slug
photo.image.save('%s.%s' % (slug,format), ContentFile(image.read()))
try:
photo.save()
except:
print 'Errorea irudi honekin', photo.title
"""
photo.title_slug = photo.title_slug + '_2'
photo.save()
"""
return photo