当前位置: 首页>>代码示例>>Python>>正文


Python News.author方法代码示例

本文整理汇总了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")
开发者ID:princenju,项目名称:ebayWithVoice,代码行数:15,代码来源:views.py

示例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'))
开发者ID:berc-web,项目名称:berc_web,代码行数:19,代码来源:__init__.py


注:本文中的models.News.author方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。