Opened 12 years ago

Last modified 6 years ago

#18867 closed Cleanup/optimization

Restoring YAML fixtures with DateTimeField causes timezone warnings — at Initial Version

Reported by: aigarius@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: michi.schwarz@…, tehfink Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Loading a YAML fixture with a timezone aware DateTimeField in Django 1.4 will cause the following warning even if the field is defined with timezone information in the YAML file

django/db/models/fields/init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-08-27 13:01:56.784734) while time zone support is active.

Excerpt from testdata.yaml

[...] , insert_date: !!timestamp '2012-08-27 13:01:56.784734+00:00', [...]

The test data is loaded by adding "fixtures = testdata" at the start of a test case class.

This bug is mentioned in Django test suite - django/trunk/tests/modeltests/timezones/tests.py:SerializationTests

Note: the trick of "MyTests = override_settings(USE_TZ=False)(MyTests)" (from #17940) often does not work as expected, because you can then get "ValueError: SQLite backend does not support timezone-aware datetimes when USE_TZ is False" during fixture loading

Change History (0)

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