manage.py dumpdata --format=yaml produces naive datetimes in fixtures
|Reported by:||disturbedmime||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The following runtime warnings are produced when --format=yaml is used with manage.py dumpdata:
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/init__.py:903: RuntimeWarning: DateTimeField User.last_login received a naive datetime (2013-12-08 07:47:16.243704) while time zone support is active.
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/init__.py:903: RuntimeWarning: DateTimeField User.date_joined received a naive datetime (2013-12-08 07:47:16.243704) while time zone support is active.
These warnings are easily reproducible with no custom application code. The following steps can be used to replicate the warnings:
Using 1.6/Python 2.7:
- django-admin.py startproject dummy_project
- cd dummy_project
- python manage.py startapp dummy_app
- Edit dummy_project/settings.py and add 'dummy_app' to INSTALLED_APPS
- python manage.py syncdb
- Create new superuser as part of syncdb process.
- mkdir dummy_app/fixtures
- python manage.py dumpdata --format=yaml --indent=4 > dummy_app/fixtures/initial_data.yaml
- python manage.py flush
- Do NOT create a new user, as the above YAML dump should contain a superuser.
- The above runtime warnings are generated.
Repeating the above steps using JSON produces no warnings. Note that the datetime format generated during the JSON dump is different.
An initial glance using the above test would indicate that the warnings are only cosmetic, and that the data is inserted into the database correctly, however, given the issue either generating the correct format, or interpreting the given format, this may lead to other problems and probably shouldn't be left to chance.
Examples of format dumps to show differences:
JSON: "last_login": "2013-12-08T08:10:52.397Z"
YAML: last_login: 2013-12-08 08:10:52.397046+00:00
Both of these were dumps using the above steps, based on the same data, and making no other changes to the DB.