Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django的South未冻结自定义字段_Python_Django_Django South - Fatal编程技术网

Python Django的South未冻结自定义字段

Python Django的South未冻结自定义字段,python,django,django-south,Python,Django,Django South,在我的Django模型中,我根据本教程创建了一个名为LocationField的自定义字段 现在我的问题是,使用南方移民似乎不起作用。它给了我一个错误 ! Cannot freeze field 'SilverInningsHelpline.classified.location' ! (this field has class SilverInningsHelpline.widgets.LocationField) ! South cannot introspect some fields;

在我的Django模型中,我根据本教程创建了一个名为LocationField的自定义字段

现在我的问题是,使用南方移民似乎不起作用。它给了我一个错误

! Cannot freeze field 'SilverInningsHelpline.classified.location'
! (this field has class SilverInningsHelpline.widgets.LocationField)

! 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
为了解决这个问题,我添加了由South文档定义的检查规则,如下所示:

from south.modelsinspector import add_introspection_rules
add_introspection_rules([
    (
        [Classified],
        [],
        {
            "location": ["LocationField", {"blank": "true"}]
        }
    )
], ["^southut\.fields\.Classified"])
class Classified(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=256)
    contact_person = models.CharField(max_length=300)
    email = models.CharField(max_length=100)
    address = models.ForeignKey(Address)
    subcategory = models.ForeignKey(Subcategory)
    phone_number = models.BigIntegerField(max_length=20, default=0)
    secondary_number = models.BigIntegerField(max_length=20, default=0, blank=True)
    more_numbers = models.CharField(max_length=300, default='', blank=True)
    image = S3DirectField(upload_to='s3direct', blank=True)
    description = models.TextField(max_length=1000, blank=True)
    location = LocationField(blank=True, max_length=255)
其中分类模型包含LocationField。我的分类模型如下:

from south.modelsinspector import add_introspection_rules
add_introspection_rules([
    (
        [Classified],
        [],
        {
            "location": ["LocationField", {"blank": "true"}]
        }
    )
], ["^southut\.fields\.Classified"])
class Classified(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=256)
    contact_person = models.CharField(max_length=300)
    email = models.CharField(max_length=100)
    address = models.ForeignKey(Address)
    subcategory = models.ForeignKey(Subcategory)
    phone_number = models.BigIntegerField(max_length=20, default=0)
    secondary_number = models.BigIntegerField(max_length=20, default=0, blank=True)
    more_numbers = models.CharField(max_length=300, default='', blank=True)
    image = S3DirectField(upload_to='s3direct', blank=True)
    description = models.TextField(max_length=1000, blank=True)
    location = LocationField(blank=True, max_length=255)

任何解决这一问题的建议都将不胜感激

看来你根本没看医生

  • 您正在传递模型类(
    Classified
    ),其中
    add\u instrspection\u rules
    需要您的字段类(
    LocationField

  • “关键字参数”dict应该描述字段所需的关键字参数,而不是描述字段在给定模型类中的使用方式

  • 末尾的限定字段名模式应该与字段的限定名称相匹配,而不是教程中的内容与模型类名的任意组合


  • 谢谢你的粗鲁解释。你的解决方案无论如何都不管用。无论如何,谢谢。@Newtt:谢谢你的粗鲁评论。我利用业余时间阅读了你的帖子,阅读了文档,并给出了一个答案,指出了你代码中至少三个明显的错误,我认为这就是“修复此问题的建议”。如果您试图修复代码,但又出现了另一个错误,请更新您的帖子。哦,是的,在陈述显而易见的事情时没有什么不礼貌的地方,
    add\u introspection\u rules
    所期望的是有文档记录的,而且我从来没有遇到过在文档之后向南方添加inspection rules的问题。