在Django模型中使用python模型

2024-04-29 08:13:04 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是我的模型.py对于我的Django应用程序:

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的数组数据类型。在

显然,我安装了在虚拟环境中键入的包:

^{pr2}$

当我同步并运行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模块?在

谢谢


Tags: djangofrompy模型importappherokumodels