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


Python News.content方法代码示例

本文整理汇总了Python中models.News.content方法的典型用法代码示例。如果您正苦于以下问题:Python News.content方法的具体用法?Python News.content怎么用?Python News.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.News的用法示例。


在下文中一共展示了News.content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_news

# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import content [as 别名]
def add_news(req):
    check = News.objects.filter(link=req.POST['link'])
    mnews = ""
    if check.count() != 0:
        # record already exist
        if check[0].time > int(req.POST['time']):
            return HttpResponse(json.dumps({'status':'OK'},indent=4),content_type='application/json')
        mnews = check[0]
    else:
        mnews = News()
    mnews.title = req.POST['title']
    mnews.content = req.POST['content']
    mnews.link = req.POST['link']
    mnews.time = int(req.POST['time'])
    mnews.save()
    keywords = json.loads(req.POST['keywords'])
    refers = json.loads(req.POST['refers'])
    for word in keywords:
        mkeywords = Keywords()
        mkeywords.news = mnews
        mkeywords.words = word
        mkeywords.save()
    for refer in refers:
        mrefer = Refers()
        mrefer.news = mnews
        mrefer.refer = refer
        mrefer.save()
    return HttpResponse(json.dumps({'status':'OK'}),content_type='application/json')
开发者ID:randoms,项目名称:prophet,代码行数:30,代码来源:views.py

示例2: post

# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import content [as 别名]
 def post(self):
     news = News()
     news.title = self.request.get("title")
     news.slug_title = self.request.get("slug_title")
     news.content = self.request.get("content")
     news.when_published = datetime.utcnow()
     news.put()
     self.response.out.write(news.to_json("title", "is_deleted", "is_active", "is_starred"))
开发者ID:aswadrangnekar,项目名称:tiss-secure,代码行数:10,代码来源:api.py

示例3: admin_news_uploads

# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import content [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.content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。