If I correctly understand you issue is to get part of the date for each item in a list of datetime.datetime or datetime.date objects.
To do this you can process the list after the query
To do this you can process the list after the query
new_list = [item.year for item in item]
But if your need is to extract fields from the objects in the result list you may use values() or values_list().
Let me know if this answers your question.
Regards,
Leo
Leo
Leonardo Giordani
Author of The Digital CatMy profile on About.me - My GitHub page - My Coderwall profile
2014-05-27 12:40 GMT+02:00 Helton Alves <homemcoisa.helton@gmail.com>:
Hi guy.
so, A don't is understand very well.
but the django has the generic date views, I think is exactly this.2014-05-27 9:06 GMT+01:00 hito koto <hitokoto2014@gmail.com>:
Hi,--
I want to get only year and get only month,
i want to get the only : 2005 and 05-27
How can i to do?
I know this :>>> Entry.objects.dates('pub_date', 'year') [datetime.date(2005, 1, 1)] >>> Entry.objects.dates('pub_date', 'month') [datetime.date(2005, 2, 1), datetime.date(2005, 3, 1)] >>> Entry.objects.dates('pub_date', 'day') [datetime.date(2005, 2, 20), datetime.date(2005, 3, 20)] >>> Entry.objects.dates('pub_date', 'day', order='DESC') [datetime.date(2005, 3, 20), datetime.date(2005, 2, 20)] >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day') [datetime.date(2005, 3, 20)]
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/f6351f85-5dbf-47f3-a475-122fb52e6fa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Helton Alves
Desenvolvedor web
Graduado em Sistemas de Informação - FACIMP
Cursando Metodologia do Ensino Superior - INESPO--To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABcoSmBznZKLD9uWa3nkW0-Tw6QPT7GJ8tTyS6FFYLUx-6U1Qw%40mail.gmail.com.
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.
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/CAEhE%2BOnBTqWSpMJkU14vc%3DYW9cs16fNtGYyZVW%2Bdq2GVVmfaFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment