[英]How to fix Django South issue with regards to localflavor in Django 1.5?
I'm starting a new project and I'm using Django 1.5. 我正在开始一个新项目,我正在使用Django 1.5。 I found out that the localflavor stuff has been removed from Django 1.5 and is now a separate installable package.
我发现localflavor的东西已经从Django 1.5中删除了,现在是一个单独的可安装包。 So I installed it.
所以我安装了它。 In my models.py I'm importing the US localflavors to get my states:
在我的models.py中,我正在导入US localflavors来获取我的状态:
from django_localflavor_us.models import USStateField
In my model, I have this field: 在我的模型中,我有这个领域:
state = USStateField(default='VA')
When I attempt to run a migration with South, I get the following message now: 当我尝试使用South运行迁移时,我现在收到以下消息:
! ! Cannot freeze field 'playerstats.location.state' !
无法冻结字段'playerstats.location.state'! (this field has class django_localflavor_us.models.USStateField)
(此字段包含类django_localflavor_us.models.USStateField)
! ! South cannot introspect some fields;
南方不能反省某些领域; this is probably because they are custom !
这可能是因为他们是定制的! fields.
领域。 If they worked in 0.6 or below, this is because we have removed the !
如果他们在0.6或以下工作,这是因为我们已经删除了! models parser (it often broke things).
模型解析器(它经常破坏东西)。 !
! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork
要解决此问题,请阅读http://south.aeracode.org/wiki/MyFieldsDontWork
I read through the wiki article, but I find it very verbose and complex. 我阅读了维基文章,但我发现它非常冗长和复杂。 My USStateField isn't considered a custom field now in 1.5 is it?
我的USStateField现在不被认为是1.5中的自定义字段了吗? Has anyone else run into this issue in 1.5?
还有其他人在1.5中遇到过这个问题吗? And how did you resolve it?
你是怎么解决的?
As of django-localflavor version 1.0, simply adding "localflavor" to your INSTALLED_APPS
is all you need to get South to properly pick it up. 从django-localflavor版本1.0开始,只需在
INSTALLED_APPS
添加“localflavor”就可以让South正确地选择它。 https://django-localflavor.readthedocs.org/en/latest/?highlight=south#installation https://django-localflavor.readthedocs.org/en/latest/?highlight=south#installation
您是否尝试过添加内省规则?
add_introspection_rules([], ["^django_localflavor_us\.models\.USStateField"])
I had to tweak Hedde van der Heide's solution to get mine to work. 我不得不调整Hedde van der Heide的解决方案让我的工作。 It looks like this:
它看起来像这样:
add_introspection_rules([], ["^localflavor\\.us\\.models\\.USStateField"])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.