本文整理汇总了Python中models.News.time方法的典型用法代码示例。如果您正苦于以下问题:Python News.time方法的具体用法?Python News.time怎么用?Python News.time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.News
的用法示例。
在下文中一共展示了News.time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_news
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import time [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')