本文整理匯總了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')