Re: Model with mix of timezone aware and naive datetimes?

2017-06-22 Thread Melvyn Sopacua
On Thursday 22 June 2017 15:19:18 Antonis Christofides wrote:

> BTW, your decision to use a naive time for departure and arrival is
> going to give you headaches unless you can be absolutely certain 
that
> you will never have a departure or arrival that occurs during the
> ambiguous hour during the autumn switch to standard time.

Naive times are fine, as long as you convert to UTC before saving 
and treat them as in UTC when loading. Of course, Django aware 
does this for you, but if your input (like from an external source) is 
guaranteed to be UTC then save some electrons.
-- 
Melvyn Sopacua

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2376308.2UvkeuZ4YT%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: Model with mix of timezone aware and naive datetimes?

2017-06-22 Thread Antonis Christofides
Hello,

I don't believe that the warning has to do with your mixing of naive and aware
fields in the same model. More likely the problem is elsewhere in your code.
XXX.timestamp is aware, and somehow your code provides it with naive data
(irrespective of what happens in the other field).

BTW, your decision to use a naive time for departure and arrival is going to
give you headaches unless you can be absolutely certain that you will never have
a departure or arrival that occurs during the ambiguous hour during the autumn
switch to standard time.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com

On 2017-06-22 05:49, Chris Beck wrote:
> I a model that requires both timezone aware and naive datetimes. To be
> specific, I am modelling a travel segment where the standard for departure and
> arrival is to always use current local time, regardless of tz/dst/ as well
> as an approved_on field that should have a tz.
>
> Is there anyway to declare the desired timezone support for the datetime field
> in the model? I'm trying to avoid "RuntimeWarning: DateTimeField XXX.timestamp
> received a naive datetime" warning spam in my output.
>
>
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a24aa1dd-95a1-47ba-93fc-01841b982083%40googlegroups.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90d51602-227b-f15e-5f47-b6d7c57c97b7%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model with mix of timezone aware and naive datetimes?

2017-06-22 Thread Александр Христюхин (roboslone)
Why don't you store all your time as tz-aware and let views decide how to 
display them?

> On 22 Jun 2017, at 05:49, Chris Beck  wrote:
> 
> I a model that requires both timezone aware and naive datetimes. To be 
> specific, I am modelling a travel segment where the standard for departure 
> and arrival is to always use current local time, regardless of tz/dst/ as 
> well as an approved_on field that should have a tz.
> 
> Is there anyway to declare the desired timezone support for the datetime 
> field in the model? I'm trying to avoid "RuntimeWarning: DateTimeField 
> XXX.timestamp received a naive datetime" warning spam in my output.
> 
> 
> 
> -- 
> 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 https://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/a24aa1dd-95a1-47ba-93fc-01841b982083%40googlegroups.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/E0260CC8-081C-41CD-A809-CB50656CAC34%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Model with mix of timezone aware and naive datetimes?

2017-06-22 Thread Chris Beck
I a model that requires both timezone aware and naive datetimes. To be 
specific, I am modelling a travel segment where the standard for departure 
and arrival is to always use current local time, regardless of tz/dst/ as 
well as an approved_on field that should have a tz.

Is there anyway to declare the desired timezone support for the datetime 
field in the model? I'm trying to avoid "RuntimeWarning: DateTimeField 
XXX.timestamp received a naive datetime" warning spam in my output.


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a24aa1dd-95a1-47ba-93fc-01841b982083%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.