def insertNews(self, news): for dn in news: try: tmp = New(**dn) tmp.save() except: print(tmp) return True
def insert_news(self, newsList): for news in newsList: try: temp_news = New.objects.filter(url=news['url']) if len(temp_news) == 0: tmp = New(title=news['title'], content=news['content'], author=news['author'], brand_id=news['brand_ID'], sub_id=news['sub_ID'], date=news['date'], url=news['url']) tmp.save() except: print(news) return True
def insert_news(self, newsList): for news in newsList: try: temp_news = New.objects.filter(url=news['url']) if len(temp_news) == 0: # tmp = New( # title=news['title'], # content= news['content'], # author= news['author'], # brand_id=news['brand_id'], # sub_id= news['sub_id'], # date=news['date'], # url=news['url'], # ) tmp = New(**news) tmp.save() except Exception as e: print(e) return True
def insertNews(self, news): for dn in news: tmp = New(**dn) tmp.save() return True