Opened 11 years ago
Closed 11 years ago
#21578 closed Bug (duplicate)
manage.py dumpdata --format=yaml produces naive datetimes in fixtures
Reported by: | James Schneider | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | jrschneider83@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
RuntimeWarning)
/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.
RuntimeWarning)
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.
Change History (3)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
(forgot to close the ticket)
Hi,
This is a duplicate of #18867 which was marked as invalid because this is a bug in the PyYAML library and not in Django.
That ticket is fairly old so if there's been new developments, feel free to reopen that other ticket so that we can keep the discussion in one place.
Thanks.