10

I have a currently empty Geodjango app set up - I am connected to my Postgis database in which I have a table named aadf that I am attempting to create a model from. I am using inspectdb to do this.

I get the following error message:

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 **

The connection to the database evidently seems fine as it is able to pick up the relevant table name. That said, it also seems to be trying to inspect the other tables Django has created in the database such as 'auth_group' and 'auth_group_permissions'.

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39
Jamie
  • 277
  • 4
  • 19

1 Answers1

20

I got this error and found that it was caused by using psycopg2 version 2.8 (or 2.8.1) -- downgrading to 2.7.7 made it go away. This is on Windows 10 with Django 2.2.

Edit: I see now that there's a fix in the pipeline for Django 2.2 to support psycopg2 2.8.

Edit (5/1/2019): Django 2.2.1 is out today with a fix adding support for psycopg2 2.8.

dhobbs
  • 3,357
  • 1
  • 18
  • 19
  • 1
    Thank you so so much for this. Project was at a complete standstill and wouldn't have been able to work this out. EDIT: I used the following command to downgrade psycopg2 'pip install psycopg2==2.7.7 --force-reinstall' – Jamie Apr 09 '19 at 20:06
  • What is the bug# for this? Would be helpful to track the version with the fix! – myartsev Apr 19 '19 at 16:28
  • FWIW: also pip of psycopg2-2.8.5-cp38-cp38-linux_x86_64.whl with Django 1.11 worked – Romain Jul 13 '20 at 21:23