def create_stock_data(): stock_list = business() for stock in stock_list: new_stock = Stock() new_stock.business = stock['business'] new_stock.code = stock['code'] new_stock.title = stock['title'] new_stock.graph_url() new_stock.stock_reset() new_stock.save()
def get(self, request): stocks = ts.get_stock_basics() for code in stocks.index: print not Stock.objects.filter(code=code).exists() print Stock.objects.filter(code=code).exists() if not Stock.objects.filter(code=code).exists(): stock = Stock() stock.code = code stock.save() return HttpResponse(json.dumps({"status": "success"}), content_type="application/json")