<tonykyriakidis@gmail.com> wrote:
> How can I use order_by and filter at the same time? (drives me
> nuts..!!!)
>
> This is what i tried:
>
> from django.shortcuts import render_to_response
> from vidupdate.posts.models import Entry
> from datetime import datetime #( I even imported the date only)
>
>
> def entry_view(request):
> entries = Entry.objects.all().filter(posted.date ==
> today).order_by('pushes')
>
> def entry_view(request):
> entries =
> Entry.objects.all().filter(date.today()).order_by('pushes')
Yep, that is not how you filter a queryset. You must specify which
field to filter, and how you want to filter.
Eg:
Entry.objects.filter(pub_date__lt=date.today())
See the (extensive) docs:
https://docs.djangoproject.com/en/1.3/topics/db/queries/#field-lookups
Cheers
Tom
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment