【发布时间】:2014-06-04 02:35:50
【问题描述】:
以下是我的 Django 应用程序的 models.py:
from django.db import models
from djorm_pgarray.fields import ArrayField
from djorm_expressions.models import ExpressionManager
class Device(models.Model):
child_devices = ArrayField(dbtype='text')
....
所以基本上,我使用名为“djorm_pgarray”的 python 模型在我的 Django 模型中使用 Postgresql 的 ARRAY 数据类型。
显然我安装了在虚拟环境中键入的包:
pip install djorm-ext-pgarray
当我同步并运行 Django 服务器并尝试加载管理页面时,我收到此错误:
ImportError at /admin/
No module named djorm_pgarray
Request Method: GET
Request URL: http://agile-woodland-9781.herokuapp.com/admin/
Django Version: 1.6.2
Exception Type: ImportError
Exception Value:
No module named djorm_pgarray
Exception Location: /app/app_search/models.py in <module>, line 2
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.6
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages']
Server time: Sat, 19 Apr 2014 17:52:35 +0000
如何在 Django 模型中导入和使用 python 模块?
谢谢
【问题讨论】:
-
我看到你正在使用 heroku。您是否记得将 djorm-ext-pgarray 添加到您的
requirements.txt文件中? -
用pip安装的时候virtualenv激活了吗?
标签: python django postgresql heroku