It's hard to answer without seeing what's in your db, and what are the
values of ano/mes/dia variables, but:
- maybe you do not have pytz package installed (you can install with 'pip
install pytz') - though in that case you should get an error when trying to
access the results
- maybe the day and month in db are different than what you are querying
for?
Does the same method called in django-shell returns some results - if so,
maybe there's some logic in your view that prevents non-empty results to be
displayed?
If that does not help, try posting the results of Model.objects.all and
your view - that should help in troubleshooting.
W dniu niedziela, 21 grudnia 2014 15:04:49 UTC+1 użytkownik Rafael Borella
napisał:
>
> Hi, i'm new in django and python,
>
> I'm trying to create a queryset to filter according to date.
>
> this is my MODEL : data = models.DateTimeField()
>
> and my VIEW: def resultado(request, dia, mes, ano):
> lista_de_balada=
> Balada.objects.filter(data__year=ano, data__month=mes, data__day=dia)
> context = {'lista_de_balada':lista_de_balada}
> return render(request, 'procurar.htm', context)
>
> it presents no errors, but the query is aways empty... if i take off
> __month
> and __day it works fine. but i need to filter according to date
> not only year.
>
> Sorry for the english, is not my native language.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/44cc0f80-920e-43c6-a2e8-db9c7b817901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.