Jump to content

Successfully Runnig Django 1.5.1 On Heliohost


Recommended Posts

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
sys.path.append("/home/username/myapp");
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

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...