5π
β
I can reproduce the error message like this:
In [58]: import datetime as DT
In [59]: eventdate = DT.datetime(2013, 6, 18, 2, 50)
In [60]: print(eventdate)
2013-06-18 02:50:00
In [61]: import dateutil.parser as parser
In [62]: parser.parse(eventdate)
AttributeError: 'datetime.datetime' object has no attribute 'read'
So on this basis it seems as though eventdate
is probably already a datetime.datetime
object. If so, there is no need to call
date_iso = dateutil.parser.parse(eventdate)
To convert it to a string
in ISO8601 format, use
In [66]: eventdate.isoformat()
Out[66]: '2013-06-18T02:50:00'
π€unutbu
0π
The error is quite clear: youβre passing in a datetime
object when in fact parse
expects a string.
- [Django]-Getting Illegal instruction: illegal hardware instruction python manage.py runserver on Apple M1 chip
- [Django]-Django β Using context_processor
- [Django]-How to filter objects by price range in Django?
Source:stackexchange.com