本文整理汇总了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')
示例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"))
示例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'))