Deploying Django at alwaysdata.com
Here's the alwaysdata wiki entry for setting up Django with fastcgi. Only down-side: it's written in French.
Well, I don't speak French, but what it basically says is:
- Create a directory named
public
in the folder of your django project. In that directory create the file
django.fcgi
with the following content:#!/usr/bin/pythonimport os, sys_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.insert(0, _PROJECT_DIR)sys.path.insert(0, os.path.dirname(_PROJECT_DIR))_PROJECT_NAME = _PROJECT_DIR.split('/')[-1]os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % _PROJECT_NAMEfrom django.core.servers.fastcgi import runfastcgirunfastcgi(method="threaded", daemonize="false")
Next, create a .htaccess in the
public
folder with the following content:AddHandler fcgid-script .fcgiRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
If you're planning to include the django admin interface, create this symbolic link in your
public
directory:ln -s /usr/local/alwaysdata/python/django/1.1/django/contrib/admin/media/ media
In the end your folder tree hierarchy should somehow look like this:
myproject/ __init__.py manage.py public/ django.fcgi .htaccess media/ settings.py urls.py myapp/ views.py models.py
Hope this helps. I talked with the admin, and he said he will soon provide an English wiki. Let's hope this is going to happen anytime soon.
UPDATE: There is an English wiki article now.
You are trying to mix two different web server integration methods: fcgi (fast cgi) and wsgi.
Your first snippet is for a wsgi interface with the web server and is the recommended method for integrating Django with Apache. Very good resources (including examples) to help you set this up correctly can be found in the official Django docs How to use Django with Apache and mod_wsgi and the mod_wsgi docs Integration with Django
The second snippet (with AddHandler line) is for fcgi. This is the kind of interface that is more typically used to interface Django with the lighttpd and nginx web servers. Resources for setting up fcgi interface can be found in official Django docs How to use Django with FastCGI, SCGI, or AJP.
Since it looks like alwaysdata.com only uses FastCGI (fcgi) interface you are stuck with this method. It looks like there are examples on their wiki page Déployer une application Django and particulary you'll need to replace your first (wsgi) snippet with this:
#!/usr/bin/pythonimport os, sys_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.insert(0, _PROJECT_DIR)sys.path.insert(0, os.path.dirname(_PROJECT_DIR))_PROJECT_NAME = _PROJECT_DIR.split('/')[-1]os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % _PROJECT_NAMEfrom django.core.servers.fastcgi import runfastcgirunfastcgi(method="threaded", daemonize="false")