Django is an open-source web platform built in Python, focused on simplifying complex database systems in an efficient manner. To install Django on a hosting package, perform the following steps:
- Upload the application files to a directory outside of public - for example: "myDjangoApp"
- Create a dispatch script inside public directory - it will process all requests to your app
- Save the file as: django.py
- Make it executable
- Paste the contents below and edit as necessary:
#!/usr/bin/python
import sys, os
# Django module path - do not edit
sys.path.insert(0, "/usr/local/lib/python2.7/dist-packages")
# EDIT - path to your app
sys.path.insert(0, "/vhome_test/45/12345/mydomain.ca/myDjangoApp")
# Switch to the directory of your project. (Optional.) # os.chdir("/home/user/myproject")
# EDIT - Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myDjangoApp.settings"
from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false") -
Create a .htaccess file inside the public directory to catch all web requests and redirect them to the dispatch script. This file does not require modification, use it as it is.
# django redirect
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.py/$1 [QSA,L] -
Perform any additional configuration your application requires, such as DB access, etc.
Comments
0 comments
Please sign in to leave a comment.