简体   繁体   English

ValueError:南部模式迁移和数据迁移的日期超出月份范围

[英]ValueError: day is out of range for month on south schemamigration and datamigration

TL;DR: Has anyone ever seen schemamigration and datamigration fail with south v. 0.8.4 raising a ValueError: day is out of range for month? TL; DR:有谁曾见过schemamigration和datamigration在South v。0.8.4引发ValueError时失败:月超出日期范围了?

I'm working on a rather large application that's got a lot of developers working at the same time - so chances are that this is something much more complicated and I'm limited in what I can share in terms of source code, so apologies to all for the cruddily-formed question. 我正在开发一个相当大的应用程序,其中有很多开发人员在同一时间工作-因此,这可能会变得更加复杂,而且我在源代码方面的共享能力受到限制,因此很抱歉所有这一切都来自于残酷形成的问题。 I needed to update a CharField to increase its max length, and just like yesterday I ran: 我需要更新CharField以增加其最大长度,就像昨天我跑了一样:

python manage.py schemamigration <appname> update_char_field_ length --auto

and while it worked yesterday to create the relevant table, today I get: 虽然昨天它在工作以创建相关表,但今天我得到:

ValueError: day is out of range for month

with no traceback info at all. 根本没有回溯信息。

So for giggles I ran ... datamigration <appname> test --stdout and get the same. 所以我为... datamigration <appname> test --stdout跑了... datamigration <appname> test --stdout并得到了相同的结果。 I was wondering if anyone has run into this before, or if not, does anyone know of a way to get south's datamigration to operate more verbosely so I might be able to trace this down in source faster? 我想知道以前是否有人遇到过这种情况,或者是否有人知道让南方的数据迁移更冗长地操作的方法,这样我也许可以更快地从源头上追溯到此?

What's weird is that I've rolled back the changes in git to a couple of days ago and reloaded the database snapshot from scratch and still get the error. 奇怪的是,我已经将git中的更改回滚到几天前,并从头开始重新加载了数据库快照,但仍然收到错误。

This actually probably doesn't have to do with your code per se as much as it has to do with Today's date! 实际上,这可能与代码本身无关,而与今天的日期无关! Somewhere you're trying to get a date that doesn't exist. 您尝试在某个地方获取不存在的日期。

One example would be if there is logic somewhere to get the last day of previous month and the code is looking for the 31st of June, which doesn't exist. 一个示例是,如果有某种逻辑可以获取上个月的最后一天,并且代码正在查找6月31日,则该日期不存在。

Without being able to share code it's impossible to see where that's happening, but hopefully that points you in the right direction. 如果无法共享代码,就无法看到发生了什么,但是希望可以为您指明正确的方向。

Closing the issue - for anyone who might look at this, it did indeed have to do with the fact that it's the first of the month. 解决问题-对于可能会看到此问题的任何人,确实确实是因为它是本月的第一天。 The problem lived in one of the functions that populates default values while generating the migration files, it was just a matter of digging through source code until I could find it... 该问题存在于生成迁移文件时填充默认值的函数之一中,这只是挖掘源代码的问题,直到我找到它为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM