I have poured many times on the site and have not found a solution that works for me. Time listener, first time caller.
I have an existing Django application (based on the Django sample documentation site, including polls). I moved this and ran it on the web server via wsgi.
I created a new local project of my own content. I did it the same way as an example site with an application at the same level as the main application of the project.
Now I am trying to add the application that I created to the sample site. I am trying to reflect the organization and plumbing for the polls app, as it connects to mysite.
My file structure is as follows:
- passenger_wsgi.py
- Mysite
- mysite (main application)
__init__.py- settings.py
- urls.py
- wsgi.py
- polls (example site application)
__init__.py- urls.py
- views.py
- models.py
- Kernel (the application I am adding)
__init__.py- urls.py
- views.py
- models.py
- manage.py
Adding settings is as follows:
INSTALLED_APPS = { 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls', 'core' }
MySite / urls.py:
from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns('', url(r'^$', 'polls.views.home', name='home2'), url(r'^polls/', include('polls.urls', namespace="polls")), url(r'^admin/', include(admin.site.urls)), url(r'^core/', include('core.urls', namespace="core")), )
kernel /urls.py:
from django.conf.urls import patterns, include, url from django.contrib import admin
When I download "manage.py shell", I can import the URLs, models, and view everything from the kernel. I can even use django.test.Client to get "/ core /", and I get a 200 response with the expected content. However, when I try to go to the site (any URL) in the browser, I get: "ImportError at No module named urls"
If I remove the call by including core.urls, the other URLs will work as expected.
I tried the number if different settings for both urls.py files, including calling the kernel .views calling directly from the top urls.py, ignoring core.urls, resulting in "No module named views".
Any advice would be greatly appreciated. I also welcome tips on how to write better questions.
Stack trace
Change I also wanted to mention that I tried to delete all compiled python files in order to exclude the possibility of unreasonable logic.
Change 2 . It works in virtualenv. I installed a newer version of Python on the Dreamhost server.
passenger_wsgi.py:
import sys, os cwd = os.getcwd() sys.path.append(cwd) sys.path.append(cwd + '/mysite') if sys.version < "2.7.9": os.execl(cwd + "/env/bin/python", "python2.7", *sys.argv) sys.path.insert(0, cwd + '/env/bin') sys.path.insert(0, cwd + '/env/lib/python2.7') sys.path.insert(0, cwd + '/env/lib/python2.7/site-packages/django') sys.path.insert(0, cwd + '/env/lib/python2.7/site-packages') os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings" from django.core.wsgi import get_wsgi_application application = get_wsgi_application()
MySite / MySite / wsgi.py:
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application()
Edit 3 : here core / views.py
from django.shortcuts import render from django.core.mail import send_mail from django.http import HttpResponseRedirect
Change 4 . Sample GET header from browser. Results in 500 Import Error; No module named url
GET /core/ HTTP/1.1 Host:
Change 5 . Since the answer basically showed that everything looks right, I expanded the scope of the question to include Dreamhost and sent a support ticket with them. I will let you know here if any of this comes out.