[Fixed]-Cant understand why i am getting a keyerror in my django python app

1👍

The key is clearly not there, otherwise you would not get a KeyError.

You do not set the key in your scrape_and_store_vlad method.

def scrape_and_store_vlad():
    ...
    entries = [{'href': url_two + div.a.get('href'),
                'src': url_two + div.a.img.get('data-original'),
                'text': div.find('p', 'entry-title').text,
                'comments': make_soup(url_two + div.a.get('href')).replace("\\", ""),
                'name': name,
                'url': url_two + div.a.get('href')
                } for div in titles][:6]

Leave a comment