Reputation: 12037
I have the following project structure:
apps(python package)
|
|
|----------trips(python package)
|----__init__.py
|----urls.py
|----views.py
project
manage.py
urls.py file has the following imports:
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required
from . import views
The app works perfectly fine when running on a local machine (I've made lots of apps like this, so I don't think the mistake is that obvious, but who knows) When I upload this to a production server (Openshift with python 3), I see Django's debug template, stating an ImportError ocurred:
ImportError at /
cannot import name views
The line of the Exception is:
from . import views
I've tried also:
from apps.trips import views
with no luck... Any ideas?
Update: This is my Python path:
Python Path:
['/var/lib/openshift/52a6379ae0b8cd1b10000001/app-root/runtime/repo',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/app-root/runtime/repo',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/psycopg2-2.5.1-py3.3-linux-x86_64.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/Django-1.6-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/django_selectable-0.7.0-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/django_autocomplete_light-2.0.0a4-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/six-1.4.1-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/South-0.8.4-py3.3.egg',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/opt/lib/python33.zip',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/opt/lib/python3.3',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/opt/lib/python3.3/plat-linux',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/opt/lib/python3.3/lib-dynload',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/virtenv/venv/lib/python3.3/site-packages/setuptools-0.6c11-py3.3.egg-info',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/python/opt/lib/python3.3/site-packages',
'/var/lib/openshift/52a6379ae0b8cd1b10000001/app-root/runtime/repo/wsgi/hector_transporte']
The last line points to my project folder (the one that contains the apps module). Another strange thing is django seems to be able to find my settings.py
I'm using the python 3 cartridge because "it's the present and future of the language"
Upvotes: 1
Views: 600
Reputation: 12037
ImportError can arise when there is a problem with the module you are importing. In this case, one of the dependences for the views module was missing on the server.
Upvotes: 0
Reputation: 3526
Is there a reason you need to use the python 3 cartridge at this time? We have a new one coming out in about 3 weeks that will be more standard. We even have a quickstart for django with the 2.7 cart - github.com/openshift/django-example
Upvotes: 1
Reputation: 61
I don't see the reference to {python_home}/Lib/site-packages/django. You might try adding that to your path.
Upvotes: 0