Friday, November 16, 2012

Re: RuntimeWarning "DateTimeField received a naive datetime" with TIMESTAMP MySQL field

On Fri, 16 Nov 2012 09:31:44 -0800 (PST)
Timster <timshaffer00@gmail.com> wrote:

> It's well-documented. Check out the Django documentation page on time
> zones:
>
> https://docs.djangoproject.com/en/1.4/topics/i18n/timezones/
>
> When time zone support is enabled, Django uses time-zone-aware
> datetime objects. If your code creates datetime objects, they should
> be aware too. In this mode, the example above becomes:
>
> import datetimefrom django.utils.timezone import utc
> now = datetime.datetime.utcnow().replace(tzinfo=utc)

https://github.com/django/django/commit/9b1cb755a2

I don't know if this is relevant but it looks so.

if settings.USE_TZ and timezone.is_naive(value):
# For backwards compatibility, interpret naive datetimes in local
# time. This won't work during DST change, but we can't do much
# about it, so we let the exceptions percolate up the call stack.
default_timezone = timezone.get_default_timezone()
value = timezone.make_aware(value, default_timezone)


It looks like it tries to make it aware but errors, that the OP reports
and what I've seen, are not following this code path. I can't tell if
it should follow this path.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate