• <small id='D5yWf'></small><noframes id='D5yWf'>

      <tfoot id='D5yWf'></tfoot>

      <i id='D5yWf'><tr id='D5yWf'><dt id='D5yWf'><q id='D5yWf'><span id='D5yWf'><b id='D5yWf'><form id='D5yWf'><ins id='D5yWf'></ins><ul id='D5yWf'></ul><sub id='D5yWf'></sub></form><legend id='D5yWf'></legend><bdo id='D5yWf'><pre id='D5yWf'><center id='D5yWf'></center></pre></bdo></b><th id='D5yWf'></th></span></q></dt></tr></i><div id='D5yWf'><tfoot id='D5yWf'></tfoot><dl id='D5yWf'><fieldset id='D5yWf'></fieldset></dl></div>
      <legend id='D5yWf'><style id='D5yWf'><dir id='D5yWf'><q id='D5yWf'></q></dir></style></legend>

        • <bdo id='D5yWf'></bdo><ul id='D5yWf'></ul>

        Loaddata 未正确处理时间戳和时区

        时间:2023-09-13

        <small id='rxJr9'></small><noframes id='rxJr9'>

              <bdo id='rxJr9'></bdo><ul id='rxJr9'></ul>

              <legend id='rxJr9'><style id='rxJr9'><dir id='rxJr9'><q id='rxJr9'></q></dir></style></legend>

              1. <tfoot id='rxJr9'></tfoot>
                  <tbody id='rxJr9'></tbody>
                <i id='rxJr9'><tr id='rxJr9'><dt id='rxJr9'><q id='rxJr9'><span id='rxJr9'><b id='rxJr9'><form id='rxJr9'><ins id='rxJr9'></ins><ul id='rxJr9'></ul><sub id='rxJr9'></sub></form><legend id='rxJr9'></legend><bdo id='rxJr9'><pre id='rxJr9'><center id='rxJr9'></center></pre></bdo></b><th id='rxJr9'></th></span></q></dt></tr></i><div id='rxJr9'><tfoot id='rxJr9'></tfoot><dl id='rxJr9'><fieldset id='rxJr9'></fieldset></dl></div>

                • 本文介绍了Loaddata 未正确处理时间戳和时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用启用了 mysql 和时区的 django 1.4.1.我将数据转储到 yaml,修改了一些字段以创建一些测试数据,并尝试将其重新加载.然而,即使指定了 tz,Django 仍然抱怨天真的日期时间

                  I'm using django 1.4.1 with mysql and timezones enabled. I did a dump data to yaml, modified some fields to create some test data, and am trying to load it back in. however, Django keeps complaining about naive datetimes even though a tz is specified

                  具体来说,我的 loaddata 有:

                  specifically, my loaddata has:

                  fields: {created_date: !!timestamp '2012-09-15 22:17:44+00:00', ...
                  

                  但是 loaddata 给出了错误:

                  but loaddata gives the error:

                  RuntimeWarning: DateTimeField received a naive datetime (2012-09-15 22:17:44) while time zone support is active.
                  

                  这对我来说没有多大意义,因为它是:

                  This doesn't make much sense to me, seeing as its:

                  1. UTC 时间戳
                  2. 与 Django 使用 dumpdata 导出的完全相同的格式

                  有什么方法可以告诉 django 这是一个 UTC 日期吗?

                  is there some way i can tell django this is a UTC date?

                  推荐答案

                  来自 docs...

                  在序列化感知日期时间时,包括 UTC 偏移量,例如这个:

                  When serializing an aware datetime, the UTC offset is included, like this:

                  "2011-09-01T13:20:30+03:00"
                  

                  对于一个天真的日期时间,显然不是:

                  For a naive datetime, it obviously isn't:

                  "2011-09-01T13:20:30"
                  

                  ...所以不是...

                  created_date: !!timestamp '2012-09-15 22:17:44+00:00'
                  

                  ...任何一个...

                  created_date: '2012-09-15T22:17:44+00:00'
                  

                  ...或...

                  created_date: '2012-09-15T22:17:44Z'
                  

                  ...会起作用的.

                  这篇关于Loaddata 未正确处理时间戳和时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:kubernetes Python API 客户端:执行完整的 yaml 文件 下一篇:'yaml.parser.ParserError: expected '&lt;document

                  相关文章

                  最新文章

                • <tfoot id='rWY3b'></tfoot>
                  • <bdo id='rWY3b'></bdo><ul id='rWY3b'></ul>

                  1. <legend id='rWY3b'><style id='rWY3b'><dir id='rWY3b'><q id='rWY3b'></q></dir></style></legend>

                      <i id='rWY3b'><tr id='rWY3b'><dt id='rWY3b'><q id='rWY3b'><span id='rWY3b'><b id='rWY3b'><form id='rWY3b'><ins id='rWY3b'></ins><ul id='rWY3b'></ul><sub id='rWY3b'></sub></form><legend id='rWY3b'></legend><bdo id='rWY3b'><pre id='rWY3b'><center id='rWY3b'></center></pre></bdo></b><th id='rWY3b'></th></span></q></dt></tr></i><div id='rWY3b'><tfoot id='rWY3b'></tfoot><dl id='rWY3b'><fieldset id='rWY3b'></fieldset></dl></div>
                    1. <small id='rWY3b'></small><noframes id='rWY3b'>