Django made easy: DjangoHosting.ch
When I first started looking at Django about two months ago, I was lamenting about how difficult it seemed (in comparison to PHP, for example) to get a simple data-driven project up and running and deployed. (Much of the difficulty is in getting MySQL running.)
Since then, of course, Google released Google App Engine and the Google App Engine Helper for Django, which make developing and deploying Python and Django applications child's play. I'd venture to say even easier than PHP (and Django/Python definitely teach you better practices in developing web applications than PHP does.)
But what if you want to deploy a non-Google App Engine Django application?
I found myself with just that need recently and the solution for me was to use DjangoHosting.ch.
DjangoHosting.ch gives you a simple one-click installer that installs and configures Django. This gets you up and running with your Django project immediately.
Beyond this, you may want to alter the automagically-created setup a bit to make it easier to develop with. Here are the steps I followed:
Create a Django project
Using the one-click installer, create a new project (e.g., "myproject")
Add your project to SVN
The one-click installer creates a project for you that's set up to use MySQL but it's not in SVN (and it should be). Modify the instructions here for your favorite version control system.
- Stop the Lighttpd server.
- Import a new project into SVN.
- SSH into your deployment server and rename the myproject folder to tmp.
- Create a new folder called myproject
- SVN Checkout into myproject
- Copy the contents tmp into myproject
- SVN Add the new files (take care if you don't want to add the pyc files).
- SVN Commit.
- Start the Lighttpd server.
At this point, your new project is in SVN and you're running the deployment server on a working copy.
(I forgot to stop the Lighttpd server before doing this and got an Internal Server Error. Manually deleting the .pid file and restarting the server fixed it. You shouldn't run into this if you remember to stop the server first.)
Check out and configure your local dev copy to use SQLite3
On my local machine, I don't want to go through the hassle of getting Django working with MySQL so I want to use SQLite3 (which comes preinstalled with Python 2.5+)
- SVN checkout a local working copy on your dev box.
- Open settings.py and settings-deployment.py in your text editor.
- Copy the database configuration (
DATABASE_ENGINE
,DATABASE_NAME
,DATABASE_USER
,DATABASE_PASSWORD
,DATABASE_HOST
, andDATABASE_PORT
) andROOT_URLCONF
from settings.py to settings-deployment.py. - In settings.py, configure the database settings to use SQLite3. Set
DATABASE_ENGINE
to'sqlite3'
andDATABASE_NAME
to the absolute path to the file you want to use as your database (it does not have to exist). e.g.'/Users/aral/myproject/trunk'
. - Commit your changes to SVN.
Finally, on your deployment server, do an SVN Update to get the latest settings updates.
That's it! At this point you should be running a local development version of your application with SQLite3 and a deployment version with MySQL and using SVN to keep everything in sync.
To deploy, just svn up
on your deployment box.
I've had a very positive experience with DjangoHosting.ch so far. They make Django deployment very simple indeed and their support department has been both affective and responsive in answering my questions.
Comments
by guy on 2009-01-03 13:13:12
by Ralf on 2009-04-28 10:54:06
by ugg boots on 2010-12-14 03:54:36