Reputation: 69
I want to get current day for now. Only day. For example today is 20-March i need use it in my queryset
query = self.filter(Q(busyrooms__end_date__day=datetime.now().date()),
Q(reservedrooms__end_date__day=datetime.now().date()))
Tried to use datetime.now().date()
but i got error
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.date'
Upvotes: 4
Views: 6589
Reputation: 11705
In django
most of the cases we use timezone. so, it's recommended to use timezone
.
from django.utils import timezone
timezone.now().date()
timezone.now().day
Upvotes: 7
Reputation: 174844
You can get the current day from datetime_obj by accessing the day
attribute of datetimeobj like datetime.now().day
Upvotes: 8