我想在我的django models.py中导入:
from django.contrib.postgres.fields import ArrayField
我读了这个文档https://docs.djangoproject.com/en/dev/ref/contrib/,我添加了"django.contrib。postgres'进入我的INSTALLED_APPS在settings.py,但当我试图同步我的db或runserver我得到" importterror: No module named postgres"
还有什么我应该做或安装的吗?Django.contrib.postgres是核心发行版的一部分,对吗?
这是trace:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "c:Python27libsite-packagesdjangocoremanagement__init__.py", line 399, in execute_from_com
utility.execute()
File "c:Python27libsite-packagesdjangocoremanagement__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:Python27libsite-packagesdjangocoremanagementbase.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "c:Python27libsite-packagesdjangocoremanagementbase.py", line 280, in execute
translation.activate('en-us')
File "c:Python27libsite-packagesdjangoutilstranslation__init__.py", line 130, in activate
return _trans.activate(language)
File "c:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 188, in activate
_active.value = translation(language)
File "c:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "c:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 159, in _fetch
app = import_module(appname)
File "c:Python27libsite-packagesdjangoutilsimportlib.py", line 40, in import_module
__import__(name)
ImportError: No module named postgres
django.contrib.postgres
将成为1.8
发布的一部分。
幸运的是,在django中有几个非官方的postgresql数组实现。其中最著名的是djorm-pgarray。另一个选择是Django - darray,当Django 1.8最终推出时,迁移应该不会太困难。