Reputation: 352
So i want to make a range from a specific date to current date.
I make like this:
context_data['newNotifications'] = Notification.objects.filter(
emailStudent=request.user).filter(time=request.user.viewedNotifications).count()
But i want all records within the time
values in range from request.user.viewedNotifications
to current time.
Upvotes: 1
Views: 193
Reputation: 3929
Have you seen the range
filter?
Basically you could do:
import datetime
# ...
context_data['newNotifications'] = Notification.objects.filter(
emailStudent=request.user).filter(
time__range=(
request.user.viewedNotifications,
datetime.datetime.now()
)
).count()
So your .filter()
argument would be time__range=(start_date,end_date)
where start_date
comes from your request and end_date
is datetime.datetime.now()
.
Upvotes: 1