如何使用PostgreSQL数据库在Django中使用ArrayField?
我想在django models.py中执行此导入:如何使用PostgreSQL数据库在Django中使用ArrayField?,django,python-2.7,django-models,django-postgresql,Django,Python 2.7,Django Models,Django Postgresql,我想在django models.py中执行此导入: from django.contrib.postgres.fields import ArrayField 我阅读了此文档,并添加了 “django.contrib.postgres”进入我在settings.py中安装的_应用程序,但当我尝试同步我的db或运行服务器时,我得到了“ImportError:没有名为postgres的模块” 还有什么我应该做或安装的吗?django.contrib.postgres是核心分销权的一部分吗 这是回
from django.contrib.postgres.fields import ArrayField
我阅读了此文档,并添加了
“django.contrib.postgres”进入我在settings.py中安装的_应用程序,但当我尝试同步我的db或运行服务器时,我得到了“ImportError:没有名为postgres的模块”
还有什么我应该做或安装的吗?django.contrib.postgres是核心分销权的一部分吗
这是回溯:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_com
utility.execute()
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 280, in execute
translation.activate('en-us')
File "c:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 130, in activate
return _trans.activate(language)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 188, in activate
_active.value = translation(language)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 159, in _fetch
app = import_module(appname)
File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 40, in import_module
__import__(name)
ImportError: No module named postgres
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“c:\Python27\lib\site packages\django\core\management\\ uuuuu init\uuuuuuu.py”,第399行,从\u com执行
utility.execute()
文件“c:\Python27\lib\site packages\django\core\management\\uuuu init\uuuuu.py”,第392行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“c:\Python27\lib\site packages\django\core\management\base.py”,第242行,运行于\u argv
self.execute(*args,**选项._dict__;
文件“c:\Python27\lib\site packages\django\core\management\base.py”,第280行,执行
翻译。激活('en-us')
文件“c:\Python27\lib\site packages\django\utils\translation\\uuuu init\uuuu.py”,第130行,在activate中
返回_trans.activate(语言)
文件“c:\Python27\lib\site packages\django\utils\translation\trans\u real.py”,第188行,在activate中
_active.value=翻译(语言)
文件“c:\Python27\lib\site packages\django\utils\translation\trans_real.py”,第177行,翻译版
默认\u translation=\u fetch(settings.LANGUAGE\u代码)
文件“c:\Python27\lib\site packages\django\utils\translation\trans\u real.py”,第159行,在\u fetch中
app=导入模块(appname)
文件“c:\Python27\lib\site packages\django\utils\importlib.py”,第40行,在导入模块中
__导入(名称)
ImportError:没有名为postgres的模块
django.contrib.postgres
将成为1.8
发行版的一部分。幸运的是,在django中有几个非官方的postgresql数组实现。最著名的人物之一。另一个选择是,当Django 1.8最终推出时,迁移应该不会太困难。谢谢,您知道Django是否有其他方法使用postgresql中的数组吗?