0

I use

python manage.py dumpdata --format yaml > test.yaml

In test.yaml I have something like that:

- fields: {test1: "my test", date: !!timestamp '2014-03-20 02:08:28+00:00', date_updated: !!timestamp '2014-03-20
      02:08:28+00:00', test: true,}

Then I use:

python manage.py loaddata test

In logs I see:

RuntimeWarning: DateTimeField Test.date received a naive datetime (2014-03-20 06:08:28) while time zone support is active.
  RuntimeWarning)

In models I have:

Class Test(models.Model):
    # many fields
    date = models.DateTimeField(auto_now_add=True, auto_now=False,)
    date_updated = models.DateTimeField(auto_now_add=False, auto_now=True,)

How to fix that warning?

Thanks.

Leon
  • 6,316
  • 19
  • 62
  • 97

1 Answers1

0

Two ways.

Shut off timezone support in your site settings. Option is USE_TZ.

The second option is to make sure you're using a time zone aware datetime object when you insert your datetime into the database. Django includes a timezone class that creates timezone aware datetime objects.

Relevant documentation: https://docs.djangoproject.com/en/1.6/topics/i18n/timezones/

pathunstrom
  • 123
  • 1
  • 7
  • I dont want shut off timezone support. I understand, that I must edit ```date``` and ```date_updated```, but how? – Leon Mar 24 '14 at 08:43
  • And I have ```RuntimeWarning: DateTimeField Session.expire_date received a naive datetime (2014-04-03 14:07:42) while time zone support is active. RuntimeWarning)```. And many-many others. – Leon Mar 24 '14 at 08:57