The following is my models.py for my Django app:
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')
....
So basically, I'm using a python model called "djorm_pgarray" to use Postgresql's ARRAY datatype in my Django Models.
Obviously I installed the packages typing within virtual environment:
pip install djorm-ext-pgarray
When I sync and run the Django server and try to load the admin page, then I get this error:
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
How can I import and use python modules in Django models?
Thanks
Make sure that:
pip install djorm-ext-pgarray
is executed from within your virtual env pip freeze > requirements.txt
updates your file properly requirements.txt
are committed to git and properly pushed to Heroku
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.