Re: Django get queryset year month day

2014-05-28 Thread Leonardo Giordani
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

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



Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2014-05-27 12:40 GMT+02:00 Helton Alves :

> Hi guy.
> so, A don't is understand very well.
>
> but the django has the generic date views, I think is exactly this.
>
>
> https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/#module-django.views.generic.dates
>
>
>
>
> 2014-05-27 9:06 GMT+01:00 hito koto :
>
> 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+unsubscr...@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
>
> --
> 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+unsubscr...@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/CABcoSmBznZKLD9uWa3nkW0-Tw6QPT7GJ8tTyS6FFYLUx-6U1Qw%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@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.


Re: Django get queryset year month day

2014-05-27 Thread Helton Alves
Hi guy.
so, A don't is understand very well.

but the django has the generic date views, I think is exactly this.

https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/#module-django.views.generic.dates




2014-05-27 9:06 GMT+01:00 hito koto :

> 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+unsubscr...@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

-- 
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+unsubscr...@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/CABcoSmBznZKLD9uWa3nkW0-Tw6QPT7GJ8tTyS6FFYLUx-6U1Qw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django get queryset year month day

2014-05-27 Thread hito koto
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+unsubscr...@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.