9👍
✅
You’ve imported the wrong thing; you’ve done from datetime import datetime
so that datetime
now refers to the class, not the containing module.
Either do:
import datetime
...article.created_on + datetime.timedelta(...)
or
from datetime import datetime, timedelta
...article.created_on + timedelta(...)
-1👍
You should use the correct import:
from datetime import timedelta
new_date = article.created_on + timedelta(0, elapsed_time_in_seconds)
👤Dos
- [Django]-How to lock access to django redis cache
- [Django]-TypeError: add() argument after * must be a sequence, not Subscribers
- [Django]-Django 'instancemethod' object has no attribute '__getitem__'
- [Django]-Django: In django-tables2 how to modify the way URLField gets rendered
-1👍
I got the same issue, i solved it by replacing
from datetime import datetime as my_datetime
with
import datetime as my_datetime
- [Django]-Django Channels stops working with self.receive_lock.locked error
- [Django]-Django: filter queryset when 2 fields have same value
- [Django]-Many to many relation. ORM Django
- [Django]-Possible to use mixins in function based views?
Source:stackexchange.com