本文整理汇总了Python中blog.models.Article.classification方法的典型用法代码示例。如果您正苦于以下问题:Python Article.classification方法的具体用法?Python Article.classification怎么用?Python Article.classification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Article
的用法示例。
在下文中一共展示了Article.classification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: article_add
# 需要导入模块: from blog.models import Article [as 别名]
# 或者: from blog.models.Article import classification [as 别名]
def article_add(request):
if request.method == 'POST':
form = ArticleForm(request.POST)
tag = TagForm(request.POST)
classification = ClassificationForm(request.POST)
if form.is_valid() and tag.is_valid() and classification.is_valid():
cd = form.cleaned_data
cdtag = tag.cleaned_data
cdclassification = classification.cleaned_data
tagname = cdtag['tag_name']
classification_name = cdclassification["classification_name"]
for taglist in tagname.split():
Tag.objects.get_or_create(tag_name=taglist.strip())
if classification_name != "":
Classification.objects.get_or_create(name=classification_name.strip())
title = cd['caption']
author = Author.objects.get(id=1)
content = cd['content']
article = Article(caption=title, author=author, content=content)
article.classification = Classification.objects.get(name=classification_name.strip())
article.save()
for taglist in tagname.split():
article.tags.add(Tag.objects.get(tag_name=taglist.strip()))
article.save()
id = Article.objects.order_by('-publish_time')[0].id
return HttpResponseRedirect('/blog/article/%s/%s/' % ('/'.join(str(article.publish_time).split()[0].split('-')), id))
else:
form = ArticleForm()
tag = TagForm(initial={'tag_name': 'notags'})
classification = ClassificationForm()
return render_to_response('article_add.html',
{}, context_instance=RequestContext(request))