On Fri, Jul 11, 2014 at 4:44 AM, Neto <paulosouzamac...@gmail.com> wrote:
> Hi guys, I need a help here:
>
>
> settings.py
>
>     TIME_ZONE = 'America/Sao_Paulo'
>
>
> view.py:
>         task = Task.objects.get(id=id)
>         task.start = request.GET['task_start']
>         tarefa.save()
>
> Terminal:
>
> RuntimeWarning: DateTimeField Task.start received a naive datetime
> (2014-07-21 07:39:14) while time zone support is active.
>
>   RuntimeWarning)
>
>
> What is it? Any solution?
>

Somewhere you are producing a naive datetime instead of a TZ aware
datetime. Find the offending place, and fix it. A good way to find the
place is to run python with -Werror ("python -Werror manage.py"). This
will turn warnings in to errors, and your program will crash when it
encounters the warning, giving you a stack trace detailing exactly
where and how you produced a naive datetime.

Fixing it, 90% of the time this means replacing "datetime.now()" with
"timezone.now()".
The other 10% of times the datetime is coming from somewhere else,
determine what TZ the naive datetime is being produced in, and use
"timezone.make_aware()" to make it a non naive, TZ aware datetime.

Full docs on TZ support functions in django:

https://docs.djangoproject.com/en/1.6/ref/utils/#module-django.utils.timezone

Cheers

Tom

-- 
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/CAFHbX1JrddyEU9gV7hqOeF8b35jZU0AOdypEwRDa5m5HjGK9Ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to