No NOT duration. I simply want to get the date_from and the date_to which is inside the DateRange.
On Friday, February 17, 2017 at 8:13:39 PM UTC+8, Александр Христюхин wrote: > > Hi, do you mean to store some kind of duration? There's DurationField for > that. And you could store datetime.timedelta there. To get timedelta > between two datetime.datetime objects, you could subtract ine from another: > > > from django.utils import timezone as tz > > now = tz.now() > day_ago = tz.now() - tz.timedelta(days=1) > duration = now - day_ago # duration can be stored in DurationField > > On 17 Feb 2017, at 04:31, RON MICHAEL <[email protected] <javascript:>> > wrote: > > Hi! In my database I have a DateRangeField. What I want to do is get the > date-from and the date-to and store them in a separate variable like > example: > > date_from =DateRangeField(date_from) > date_to =DateRangeField(date_to) > > > of course that code won't work. My data is like this: > > 'date_range': DateRange(datetime.date(2017, 2, 17), datetime.date(2017, 2, > 18), '[)') > > > > > How do I get those dates? > > Btw, I've tried indexing this, and it doesn't work. I've tried iterating > it, but it also doesn't work. > > > > -- > 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] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/848d9e95-4701-4984-bfee-64526621084e%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/848d9e95-4701-4984-bfee-64526621084e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3ff094ad-8153-4e8e-9440-80a2b0057667%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

