本文整理匯總了Python中models.News.image方法的典型用法代碼示例。如果您正苦於以下問題:Python News.image方法的具體用法?Python News.image怎麽用?Python News.image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.News
的用法示例。
在下文中一共展示了News.image方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: admin_news_uploads
# 需要導入模塊: from models import News [as 別名]
# 或者: from models.News import image [as 別名]
def admin_news_uploads():
form = UploadNewsForm()
if form.validate_on_submit():
news = News()
db.session.add(news)
db.session.commit()
news.title = form.title.data
news.content = form.content.data
news.author = current_user.username
file_name = secure_filename(form.image.data.filename)
extension = file_name.split('.')[-1]
file_name = '.'.join([str(news.id), extension])
path = upload_s3(file_name, form.image.data, app.config['S3_NEWS_IMAGE_DIR'])
news.image = path
db.session.commit()
return redirect(url_for('news_and_resources'))