TypeError at / 'NoneType' object is not iterable
cseshahriar opened this issue · 0 comments
cseshahriar commented
django_elastic_demo/home/views.py
Line 27 in eb29b98
TypeError at /
'NoneType' object is not iterable
def generate_random_data(): url = 'https://newsapi.org/v2/everything?q=apple&from=2021-04-23&to=2021-04-23&sortBy=popularity&apiKey=827705eea42e455cba8bf4afafc7da90' r = requests.get(url) payload = json.loads(r.text) count = 1 if payload.get('articles'): # please add this line for data in payload.get('articles'): print(count) ElasticDemo.objects.create( title = data.get('title'), content = data.get('description') )