Python Django 2.0.7-执行重命名字段迁移时出现语法错误

Python Django 2.0.7-执行重命名字段迁移时出现语法错误,python,django,python-3.x,migration,django-2.0,Python,Django,Python 3.x,Migration,Django 2.0,我有以下Django课程: class Contacto(models.Model): responsable_documento = models.CharField(primary_key=True, max_length=40) responsable_tipo_documento = models.CharField(max_length=20) responsable_nombre = models.CharField(max_length=50, blank=

我有以下Django课程:

class Contacto(models.Model):
    responsable_documento = models.CharField(primary_key=True, max_length=40)
    responsable_tipo_documento = models.CharField(max_length=20)
    responsable_nombre = models.CharField(max_length=50, blank=True)
    responsable_apellido = models.CharField(max_length=60, blank=True)
    responsable_telefono = models.CharField(max_length=20, blank=True)
    responsable_telefono_particular = models.CharField(max_length=20, blank=True)
    responable_email_uno = models.EmailField()
    responsable_email_dos = models.EmailField()
    responsable_email_tres = models.EmailField()
    cueanexo = models.PositiveIntegerField(null=True)

    class Meta:
        unique_together = (
            ('responsable_documento', 'responsable_tipo_documento', 'alumno_documento', 'alumno_tipo_documento'),
        )
        verbose_name_plural = 'contactos'
我正在尝试重命名一些字段:

class Contacto(models.Model):
    responsable_documento = models.CharField(primary_key=True, max_length=40)
    responsable_tipo_documento = models.CharField(max_length=20)
    responsable_nombre = models.CharField(max_length=50, blank=True)
    responsable_apellido = models.CharField(max_length=60, blank=True)
    responsable_telefono = models.CharField(max_length=20, blank=True)
    responsable_telefono_celular = models.CharField(max_length=20, blank=True)
    responable_email1 = models.EmailField()
    responsable_email2 = models.EmailField()
    responsable_email3 = models.EmailField()
    cue_anexo = models.PositiveIntegerField(null=True)

    class Meta:
        unique_together = (
            ('responsable_documento', 'responsable_tipo_documento', 'alumno_documento', 'alumno_tipo_documento'),
        )
        verbose_name_plural = 'contactos'
这将导致以下迁移:

class Migration(migrations.Migration):

    dependencies = [
        ('datos_basicos', '0008_auto_20180813_1505'),
    ]

    operations = [
        migrations.RenameField(
            model_name='contacto',
            old_name='cueanexo',
            new_name='cue_anexo',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responable_email_uno',
            new_name='responable_email1',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_email_dos',
            new_name='responsable_email2',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_email_tres',
            new_name='responsable_email3',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_telefono_particular',
            new_name='responsable_telefono_celular',
        ),
    ]
当我尝试应用所述迁移时,出现以下错误:

Running migrations:
  Applying datos_basicos.0009_auto_20180813_1731...Traceback (most recent call last):
  File "/home/desarrollo/.local/share/virtualenvs/censo_estudiantil-86GgnGcQ/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  psycopg2.ProgrammingError: syntax error at or near "WITH ORDINALITY"
  LINE 6:                     FROM unnest(c.conkey) WITH ORDINALITY co...
有人知道是什么导致了这个错误吗?

我想这是django的错误。
在我的例子中,降级到2.0版是有效的。最好的。José

切换到Django 2.1后,我收到了相同的错误消息,更新了我的Postgres版本,为我修复了这个问题。但2.1版本的支持率有所下降

该错误适用于django版本大于2.0的版本。将django版本降级为2.0,Postgres版本与9.3版本相同,这对我很有效。

我在使用Postgres 9.3时出现此错误。在切换到Postgres 9.4之后,我能够运行迁移。我的一个难题是Ubuntu在升级时保留了我的数据库版本,所以我没有注意到服务器版本回到了9.1。将数据库更新到当前版本需要一些手动步骤,因此即使安装了Postgres10,我仍然使用9.1。这帮了大忙:非常感谢兄弟让我大吃一惊的是Travis CI使用Postgres 9.2作为默认版本,但谢天谢地,您可以指定其他版本: