Jump to content


Member Since 10 Jun 2012
Offline Last Active Today, 05:58 AM

#96158 Successfully Runnig Django 1.5.1 On Heliohost

Posted by badrihippo on 21 September 2013 - 09:25 AM

I created a website using Django 1.5, and I managed to get it running on HelioHost!
Here's what I did, after following the instructions at http://www.heliohost...anguages/python...

First, I downloaded the Django-1.5.1.tar.gz file from the Django website.

Then, I extracted it and uploaded the Django-1.5.1/django/ folder to /home/username/django_1.5_override/django.
I also created an empty __init__ file in /home/username/django_1.5_override, to tell Python that it could import stuff from here. I'm not sure if it's needed, though.

I then added a few lines to the dispatch.wsgi file; the modifications are in the first 3 lines:
import os, sys
oldpath = sys.path
sys.path = ['/home/username/django_override/django-1.5.1/'] + oldpath
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
os.environ['PYTHON_EGG_CACHE'] = '/home/username/.python_egg_cache'
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler();
def application(environ, start_response):
environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO'];
try: # added so that I can see errors if they occur; should be removed once the website is fully functional
	return _application(environ, start_response)
except Exception, e:
		import traceback
		trace = traceback.format_exc()
		status = '500 Internal Server Error'
		output = trace
		response_headers = [('Content-type', 'text/plain'),('Content-Length', str(len(output)))]
		start_response(status, response_headers)
		return [output]
Basically, what I did was to add the Django 1.5.1 folder to the beginning of sys.path, so that when Python needs to import django, it imports my uploaded one instead of the default one.

After following these steps, Django 1.5.1 is running perfectly, and I can make use of all the new features! :D