Sunday, December 21, 2014

filter Datetimefield

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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/948e257d-f704-4dd5-8797-750ba253bcec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment