12👍
Use the __lt
(less than) filter lookup:
from datetime import datetime
Post.objects.filter(created__lt=datetime.today())
1👍
This should work for posts created earlier than today
from datetime import date
Post.objects.filter(created__lte=date.today())
In case you want to include post’s from today but earlier than right now use:
from datetime import datetime
Post.objects.filter(created__lte=datetime.today())
- [Django]-Django: Long field (BigIntegerField) For MongoDB
- [Django]-Celery not connecting to redis server
- [Django]-How to create a custom 404 page for my Django/Apache?
Source:stackexchange.com