Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#17934 closed Bug (fixed)

RuntimeWarning: DateTimeField received a naive datetime

Reported by: DonYang Owned by: nobody
Component: Uncategorized Version: 1.4-beta-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

/Users/*/.virtualenvs/*/lib/python2.7/site-packages/django/db/models/fields
/init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-03-19 13
:00:10.967045) while time zone support is active.

RuntimeWarning)

I use 1.4rc2, south 0.7.3.
I got this warning everytime I migrate my app. But when I changed django to 1.3.1, south has no warning.

Change History (6)

comment:1 by DonYang, 13 years ago

pip freeze

Django==1.4c2
MySQL-python==1.2.3
South==0.7.3
wsgiref==0.1.2

comment:2 by Aymeric Augustin, 13 years ago

Resolution: needsinfo
Status: newclosed

Lots of things happen when you run migrate -- for instance, initial_data fixtures are loaded. Your description doesn't contain enough information to tell if it's a bug in Django or in your code.

Did you create the project with Django 1.4c2? If you didn't, did you add USE_TZ = True in your settings file? Have you reviewed the troubleshooting section of the docs (this very problem is discussed in question 2)?

Please provide more information and reopen the ticket if you can isolate the cause of the problem and it's in Django.

Last edited 13 years ago by Aymeric Augustin (previous) (diff)

comment:3 by DonYang, 13 years ago

Resolution: needsinfo
Status: closedreopened

I used virtualenvwrapper==3.1
$mkvirtualenv mysite
$workon mysite
(mysite)$pip install Django-1.4c2.tar.gz
(mysite)$pip install south
(mysite)$tar zxvf MySQL-python-1.2.3.tar.gz
(mysite)$cd MySQL-python-1.2.3
(mysite)$vi site.cfg
uncommented mysql_config and changed -> /usr/local/mysql/bin/mysql_config
changed registry_key -> SOFTWARE\MySQL AB\MySQL Server 5.1
(mysite)$python setup.py build
(mysite)$python setup install

(mysite)$pip freeze
Django==1.4c2
MySQL-python==1.2.3
South==0.7.3
wsgiref==0.1.2

(mysite)$django-admin.py startproject mysite
(mysite)$./manage.py startapp polls
add something to models.py


from django.db import models
class Poll(models.Model):

question = models.CharField(max_length=200)


created a mysql database 'mysite' with utf-8 unicode
changed database to mysql
added south and polls to INSTALLED_APPS
USE_TZ is True by default
(mysite)$python manage.py syncdb
create superuser : no
(mysite)$python manage convert_to_south polls
got this


Creating migrations directory at '/Users/don/Workspaces/test_work/mysite/polls/migrations'...
Creating init.py in '/Users/don/Workspaces/test_work/mysite/polls/migrations'...

+ Added model polls.Poll

Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate polls

  • Soft matched migration 0001 to 0001_initial.

Running migrations for polls:

  • Migrating forwards to 0001_initial.

    polls:0001_initial[[BR]]

    (faked)

/Users/don/.virtualenvs/mysite/lib/python2.7/site-packages/django/db/models/fields/init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-03-21 02:00:29.098454) while time zone support is active.

RuntimeWarning)


App 'polls' converted. Note that South assumed the application's models matched the database
(i.e. you haven't changed it since last syncdb); if you have, you should delete the polls/migrations
directory, revert models.py so it matches the database, and try again.


and everytime I changed Poll model and migrate it always got this warning
(mysite)$python manage.py schemamigration polls --auto
(mysite)$python manage.py migrate polls


Running migrations for polls:

  • Migrating forwards to 0002_autoadd_field_poll_name.

    polls:0002_auto__add_field_poll_name[[BR]]

/Users/don/.virtualenvs/mysite/lib/python2.7/site-packages/django/db/models/fields/init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-03-21 02:05:13.321314) while time zone support is active.

RuntimeWarning)

  • Loading initial data for polls.

Installed 0 object(s) from 0 fixture(s)


I pip install pytz got nothing help.
But when I created a new virtualenv with django1.3.1, there is no warning at all.
like this


(mysite2)don$ python manage.py schemamigration polls --auto

+ Added field title on polls.Poll

Created 0002_autoadd_field_poll_title.py. You can now apply this migration with: ./manage.py migrate polls
(mysite2)don$ python manage.py migrate pollsRunning migrations for polls:

  • Migrating forwards to 0002_autoadd_field_poll_title.

    polls:0002_auto__add_field_poll_title[[BR]]

  • Loading initial data for polls.

No fixtures found.


Last edited 13 years ago by DonYang (previous) (diff)

comment:4 by Simon Charette, 13 years ago

You should really use wikiformating, it's quite hard to read your report.

BTW, latest south commit fixes something related to timezone. Can you try to reproduce using it? I think you can install *trunk* version by doing pip install https://bitbucket.org/andrewgodwin/south/get/tip.tar.gz

comment:5 by DonYang, 13 years ago

Resolution: fixed
Status: reopenedclosed

comment:6 by Aymeric Augustin, 13 years ago

Yes, time zone support was implemented in south very recently.

Note: See TracTickets for help on using tickets.
Back to Top