本文整理汇总了Python中models.News.author方法的典型用法代码示例。如果您正苦于以下问题:Python News.author方法的具体用法?Python News.author怎么用?Python News.author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.News
的用法示例。
在下文中一共展示了News.author方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addNews
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import author [as 别名]
def addNews(request):
url=request.POST['url']
news = News()
user = request.user # change to request.user
news.author = user
news.picture = open(request.FILES['picture'].temporary_file_path(), "rb")
news.voice = open(request.FILES['voice'].temporary_file_path(), "rb")#change to data from request
result=urlparse.urlparse(url)
params=urlparse.parse_qs(result.query,True)
gid=params['id']
news.good = Goods.objects(pk=gid[0]).first()
news.save()
return HttpResponse("success")
示例2: admin_news_uploads
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import author [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'))