我安装了这个包https://github.com/dracos/django-date-extensions并使用了ApproximateDateField。一切正常,直到我试图将应用程序转换为使用南方。我跑的时候
manage.py convert_to_south journals
我收到以下错误
Creating migrations directory at '/Users/MYID/Projects/MyProjectDir/MyProject/apps/journals/migrations'...
Creating __init__.py in '/Users/MYID/Projects/MyProjectDir/MyProject/apps/journals/migrations'...
! Cannot freeze field 'journals.issue.publication_date'
! (this field has class django_date_extensions.fields.ApproximateDateField)
! 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
! models parser (it often broke things).
! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork
我尝试将此添加到我使用该字段的模型文件中,但似乎没有效果
from south.modelsinspector import add_introspection_rules
....
add_introspection_rules([
(
[ddx.ApproximateDateField],
[],
{},
),
], ['^south\.tests\.journals\.models\.ApproximateDateField'])
答案 0 :(得分:1)
您是否从ApproximateDateField
导入south.tests.journals.models
?
在我看来,正则表达式与自定义Field类不匹配。您需要告诉South如何找到您自定义的字段,我假设您(我从未使用过django-date-extensions)从您导入:
django_date_extensions.fields
考虑到这一点,你应该改变这一行:
['^south\.tests\.journals\.models\.ApproximateDateField']
到此:
['^django_date_extensions\.fields\.ApproximateDateField']