本文整理汇总了Python中models.Article.viewcount方法的典型用法代码示例。如果您正苦于以下问题:Python Article.viewcount方法的具体用法?Python Article.viewcount怎么用?Python Article.viewcount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Article
的用法示例。
在下文中一共展示了Article.viewcount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submitarticle
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import viewcount [as 别名]
def submitarticle(request):
error_msg = u"No POST data sent."
if request.method == "POST":
post = request.POST.copy()
if post.has_key('tags') and post.has_key('title') and post.has_key('url'):
try:
url = post['url']
art = Article()
art.tags = post['tags'].strip().split(',')
art.author = str(request.user)
art.title = post['title']
art.votecount = 0
art.viewcount = 0
if not url.startswith('http://'):
url = 'http://'+url
art.url = url
if art.url and art.title and art.author:
try:
person = getPerson(request)
person.timesArticle = person.timesArticle + 1
person.lastActive = datetime.datetime.now()
rating = Score.objects(type='submitarticle')[0].value
person.currentRating = person.currentRating + rating
person.save()
incrementStat('articles',1)
art.save()
except Exception as inst:
print inst
return HttpResponseRedirect('/')
except:
return HttpResponseServerError('wowza! an error occurred, sorry!')
else:
error_msg = u"Insufficient POST data (need 'content' and 'title'!)"
return HttpResponseServerError(error_msg)