I've poured over the site for a while now, and haven't found a resolution that works for me. Long time listener, first time caller.
I have an existing Django application (based on the Django documentation sample site including 'polls'). I've moved this over and got it up and running on a web server via wsgi.
I have created a new local project of my own content. I did so in a manner similar to the sample site with an app on the same level as the project's main application.
I'm now trying to add the app that I created to the sample site. I'm trying to mirror 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 app)
__init__.py
- settings.py
- urls.py
- wsgi.py
- polls (sample site app)
__init__.py
- urls.py
- views.py
- models.py
- core (app that I'm adding)
__init__.py
- urls.py
- views.py
- models.py
- manage.py
- mysite (main app)
The addition to settings looks 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")),
)
core/urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
#from core import views
urlpatterns = patterns('',
url(r'^', 'core.views.home', name='home'),
)
When I load up "manage.py shell", I can import urls, models, and views all from core. 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 navigate to the site (any url) in a browser, I get: "ImportError at No module named urls"
If I remove the call to include core.urls the other urls work as expected.
I've tried a number if different tweaks to both urls.py files including calling calling core.views directly from the top urls.py ignoring the core.urls which results in "No module named views".
Any advice would be greatly appreciated. I also welcome advice on how to write better questions.
Edit: Also wanted to mention that I tried deleting all compiled python files to eliminate the possibility of unupdated logic.
Edit 2: It is running in a virtualenv. I've installed a newer version of Python on a 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's the core/views.py
from django.shortcuts import render
from django.core.mail import send_mail
from django.http import HttpResponseRedirect
# Create your views here.
def home(request):
return render(request, 'core/home.html')
Edit 4: Sample GET header from browser. Results in 500 Import Error; No module named urls
GET /core/ HTTP/1.1
Host: #redacted
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: csrftoken=36HpckIqzOMbw29BOrQWcnaIJbMn6pwo; sessionid=z9c58vb6610kevo4yytolcbhlaqsoqnm
Edit 5: Since the response has predominantly indicated that things look right, I've expanded the scope of the question to include Dreamhost and submitted a support ticket with them. I will report back here if anything useful comes of that.