Answer the question
In order to leave comments, you need to log in
How to fix date error?
in the parser, I get the date from the site, but it looks like this 14:52 01/02/2020, and I need to translate it into this 02-01-2020 14:52
I did it like this:
date = content_div.find('div', attrs={'class': 'article__info-date'}).find('a').text
date = datetime.datetime.strptime(date, '%H:%M %d.%m.%Y').strftime('%Y-%m-%d %H:%M')
RuntimeWarning: DateTimeField News.date received a naive datetime (2020-01-02 16:39:00) while time zone support is active.
RuntimeWarning)
Answer the question
In order to leave comments, you need to log in
That "02-01-2020 14:52" does not contain information about the time zone. You need to either set USE_TZ = False
or disable this setting in settings.py locally, only for this section of code, or set the time zone to the timestamp stored in date
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question