Reputation: 352
Software versions: Python: 3.5.2 Django: 1.10
I'm trying to deploy a django project onto a Dreamhost site, but whenever I try to extend my base templates it gives me a Server Error 500. My view renders just fine until I include the {% extends 'base.html' %} to the template that the view is trying to render.
What is frustrating is that with the exact same files, the local development version works fine (i.e. using python manage.py runserver).
Here is my project outline:
<website.com>
├─passenger_wsgi.py
└─simplistic
└──simplistic
| ├─__init__.py
| ├─settings.py
| ├─urls.py
| └─wsgi.py
├──main
| ├─__init__.py
| ├─urls.py
| ├─views.py
| └─templates
| └─main
| └─main.html
├──templates
| └─base.html
└──manage.py
Here is my passenger_wsgi.py file:
import sys, os
cwd = os.getcwd()
sys.path.append(cwd)
INTERP = "/home/<my_user_name>/.virtualenvs/simplistic_production/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
sys.path.append('/home/<my_user_name>/<my_website>.com/simplistic')
os.environ['DJANGO_SETTINGS_MODULE']="simplistic.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Here is the relevant part of my settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR, 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
I have also tried changing the Templates = [ 'DIRS':] entry to
/home/<username>/<website>.com/simplistic/templates
This doesn't work either.
The fact that the manage.py runserver version works while the production environment doesn't leads me to believe that there may be a problem with my passenger_wsgi.py file, but if I change any of those paths it breaks everything (i.e. I can't even access main.html with {% extends 'base.html' %} turned off).
I'm at a complete loss here. I would appreciate any help. Thanks!
Upvotes: 1
Views: 1662
Reputation: 308829
Your DIRS
setting looks wrong. You want to combine BASE_DIR
and 'templates'
.
'DIRS': [os.path.join(BASE_DIR, 'templates')],
Upvotes: 1