django.db.utils.ProgrammingError: type "int4range" does not exist

django.db.utils.ProgrammingError: type "int4range" does not exist

第一次使用 PostgreSQL 特定的数据库字段,更具体地说 IntegerRangeField。在 Debian 虚拟机上使用 Django 1.8.7、PostgreSQL 9.1.13、Psycopg2 2.6.1 和 Python 2.7.3。 运行 将 IntegerRangeField 添加到模型的迁移引发:

django.db.utils.ProgrammingError: type "int4range" does not exist

我是否必须在 PostgreSQL 中安装任何模块或扩展才能使用范围字段? (我知道必须加载一个扩展才能使用HStoreField

我是不是漏掉了什么?

Range data types 已在 PostgreSQL 9.2 中添加。您正在使用 9.1.13.

postgresql 中的范围字段从版本 9.2 开始可用(如前所述 here,它们是在 9.2 中引入的),因此您不能在 9.1.13 上使用它们,因为它们不存在。