本文整理汇总了Python中models.Image.url方法的典型用法代码示例。如果您正苦于以下问题:Python Image.url方法的具体用法?Python Image.url怎么用?Python Image.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_set
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import url [as 别名]
def store_set(self, set):
img = Image()
img.userId = self.user
img.url = set['url']
img.save()
name = "%d.%s" % (img.id, set['format'].lower())
size = set['sizes']
img.full.save(name, File(size['full']), save=False)
img.medium.save(name, File(size['medium']), save=False)
img.thumb.save(name, File(size['thumb']), save=False)
img.save()
return img
示例2: attach_image_to_project
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import url [as 别名]
def attach_image_to_project(id):
MyForm = model_form(Image, base_class=Form, exclude_fk = True, db_session=db.session, field_args={
'subtitle': {'validators' : [InputRequired()]},
'url': {'validators': [InputRequired(), URL(), valid_image_link]}}
)
image = Image(project_id = id)
form = MyForm(request.form, image)
if form.validate_on_submit():
image.subtitle = form.subtitle.data
image.url = form.url.data
db.session.add(image)
db.session.commit()
return "success", 201
return render_template("create_image.html", form=form, url = "/project/add/" + str(id) + "/image")