我想在我的django models.py中执行此导入:
from django.contrib.postgres.fields import ArrayField
我已阅读此文档https://docs.djangoproject.com/en/dev/ref/contrib/,我补充道 'django.contrib.postgres'进入settings.py中的INSTALLED_APPS,但是当我尝试同步我的db或runserver时,我得到了“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
答案 0 :(得分:4)
django.contrib.postgres
将成为1.8
发布的一部分。
答案 1 :(得分:1)
幸运的是,django中有几个非官方的postgresql数组实现。其中最值得注意的是djorm-pgarray。当Django 1.8最终推出时,另一个选择是django-dbarray,迁移不应该太困难。