Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stories.published does not take into a account publish time #4

Open
finkedave opened this issue Jan 30, 2013 · 0 comments
Open

Stories.published does not take into a account publish time #4

finkedave opened this issue Jan 30, 2013 · 0 comments

Comments

@finkedave
Copy link
Contributor

Stories published manager only takes into account the story's status and published_date. Not the publish time.

This solution works for me,

from django.db.models import Q
now = datetime.now()
current_date = now.date()
current_time = now.time()
return queryset.filter(Q(publish_date__lt=current_date)|Q(
publish_date=current_date, publish_time__lte=current_time)).filter(
status__exact=PUBLISHED_STATUS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant