0

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

2
  • I see you're using heroku. Did you remember to add djorm-ext-pgarray to your requirements.txt file? Commented Apr 19, 2014 at 18:03
  • Was the virtualenv activated when you installed with pip? Commented Apr 19, 2014 at 18:21

1 Answer 1

1

Make sure that:

  1. pip install djorm-ext-pgarray is executed from within your virtual env
  2. pip freeze > requirements.txt updates your file properly
  3. the changes to requirements.txt are committed to git and properly pushed to Heroku
Sign up to request clarification or add additional context in comments.

1 Comment

Had this same issue, was indeed a matter of not having a library installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.