本文整理汇总了Python中blog.models.Article.put方法的典型用法代码示例。如果您正苦于以下问题:Python Article.put方法的具体用法?Python Article.put怎么用?Python Article.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Article
的用法示例。
在下文中一共展示了Article.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_article
# 需要导入模块: from blog.models import Article [as 别名]
# 或者: from blog.models.Article import put [as 别名]
def create_article(self):
""" Create new article
"""
if not self.request.POST:
self.response.out.write(template.render('blog/templates/edit.html',
{'article': None,
'title': 'New article',
'action': webapp2.uri_for('create_article')}))
else:
slug = self.request.get('slug')
article = Article.get_by_key_name(slug)
if article:
slug = slug + '_to_change'
keywords = map(string.strip,
self.request.get('keywords').split(','))
article = Article(key_name=slug,
title=self.request.get('title'),
description=self.request.get('description'),
keywords=keywords,
content=self.request.get('content'))
article.put()
self.redirect('/' + slug)
示例2: create_article
# 需要导入模块: from blog.models import Article [as 别名]
# 或者: from blog.models.Article import put [as 别名]
def create_article(request):
"""Enables Article creation"""
if request.method == 'POST':
form = ArticleForm(request.POST)
if form.is_valid():
article = Article(title=form.cleaned_data['title'],
content=form.cleaned_data['content'],
author=request.session['user'].username)
article.put()
messages.add_message(request,
messages.INFO,
u'Article %s created' %
form.cleaned_data['title'])
time.sleep(1)
return redirect('home')
else:
form = ArticleForm()
return render(request, 'article/create.html', locals())