Django无法使用inspectdb对遗留数据库建模

问题描述 投票:5回答:1

我有一个当前空的Geodjango应用程序设置 - 我连接到我的Postgis数据库,其中我有一个名为aadf的表,我试图从中创建一个模型。我正在使用inspectdb来执行此操作。

我收到以下错误消息:

from django.contrib.gis.db import models
# Unable to inspect table 'aadf'
# The error was: sequence index must be integer, not 'slice'
# Unable to inspect table 'auth_group'
# The error was: sequence index must be integer, not 'slice'
# Unable to inspect table 'auth_group_permissions'
# The error was: sequence index must be integer, not 'slice'

** This error message repeats for multiple other tables that Django has created **

与数据库的连接显然很好,因为它能够获取相关的表名。也就是说,它似乎也试图检查Django在数据库中创建的其他表,例如'auth_group'和'auth_group_permissions'。

django geodjango django-2.2
1个回答
13
投票

我收到此错误,发现它是由使用psycopg2版本2.8(或2.8.1)引起的 - 降级到2.7.7使它消失。这是在Windows 10上使用Django 2.2。

编辑:我现在看到Django 2.2管道中有一个修复程序来支持psycopg2 2.8。

编辑(5/1/2019):Django 2.2.1今天已经出现了修复,增加了对psycopg2 2.8的支持。

© www.soinside.com 2019 - 2024. All rights reserved.