Several people have asked me about setting up Django on Dreamhost, so I thought I’d throw together a quick tutorial.

Although I’ve chosen to run my Django application server off Gypsy Hosting, I do have a Dreamhost account, and I have been able to run Django on it with no problems to speak of. The instructions here are based on those at the Dreamhost wiki, but I have modified a few things to suit my preferences. Also, this tutorial is more verbose, explaining things a little further.

Some slight words of caution: some people have reported problems with Django on Dreamhost. It is listed an as “Django-friendly web host” on the Django website, though, and I’ve personally not had any trouble. Also, the Dreamhost/Django setup involves running Django under FastCGI. While this is an officially supported configuration for Django, it’s not the recommended one — Django’s website states that mod_python under Apache is the preferred way. All that having been said, Dreamhost should be a perfectly adequate place for you to install and try out Django.

Prepare your Dreamhost account for Django

We’ll need to configure your Dreamhost account for use with Django. You can do this right alongside your existing website if you have one. Django will exist separately of it, so there should be no conflicts.

Add a subdomain

First, you’ll want to create a new subdomain for your Django application server. This way, you can play with Django all you like without affecting your production site. To create the subdomain:

  1. Open the Dreamhost administration panel.
  2. Choose “Manage Domains” under the Domains menu.
  3. Select “Add New Domain / Sub-Domain”
  4. Choose a name for your subdomain. I’ve chosen django.jeffcroft.com and will be using that name in this tutorial.
  5. Select both “Extra web security” and “Fast CGI Support”
  6. Click the ‘Fully host this domain now!” button.

Create a MySQL database

We’ll also need to setup a MySQL database to use with Django (sadly, Dreamhost doesn’t support PostgreSQL). Follow these steps:

  1. In the Dreamhost administration panel, choose “manage MySQL” under the Goodies menu.
  2. Enter a database name for your new database. I’ve chosen django_db and will be using that name in the tutorial.
  3. Enter a hostname for your database server. I’ve chosen djangodb.jeffcroft.com.
  4. Enter a username and password for your database.
  5. Click the “Add new database now!” button.

Create a few directories

We’ll need to create some directores for your Django install. You can do this however you like (shell, FTP, etc.), but it’s probably simplest to do it in the shell, as we’ll need the shell in a moment anyway. For these instructions, we’ll use the shell to create directories.

  1. SSH into your Dreamhost server (for me,it’s rossmore.dreamhost.com, but yours is likely different).
  2. Make a new directory for Django-related bits: mkdir django
  3. Change into your new directory: cd django
  4. Create directories for templates and projects: mkdir django_templates and mkdir django_projects
  5. Create a directory to store your media files (css, images, javascript, etc.). Be sure to use the subdomain you’ve chosen, instead of django.jeffcroft.com: mkdir ~/django.jeffcroft.com/media

Download and set up Django

We’ll be using the latest Django by checking it out from its Subversion repository.

  1. In your ~/django directory (which you should already be in), check out the source: svn co http://code.djangoproject.com/svn/django/trunk/ django_src
  2. Edit your ~/.bash_profile file, adding the following lines. This sets your Python path to include your Django directories, and puts Django’s utilities in your system path. You can edit the file however you like.

.bash_profile Bash shell

export PATH=$PATH:$HOME/django/django_src/django/bin
export PYTHONPATH=$PYTHONPATH:$HOME/django/django_src:$HOME/django/django_projects

  1. Activate your profile changes by “sourcing” the file: source ~/.bash_profile

Start a Django project

Django differentiates between “projects” and “applications.” A project can contain multiple apps. We’ll start by creating a project named “myproject.” If you choose a different name, you’ll need to modify the instructions accordingly.

  1. Move into your Django projects directory: cd ~/django/django_projects
  2. Start a new project, using Django’s command line utility. This creates a basic directory structure for the project and adds the necessary configuration files: django-admin.py startproject myproject
  3. Ensure that only you can read and write to the settings file for your project. This is very important, as your database password will be in this file: chmod 600 myproject/settings.py
  4. Edit the myproject/settings.py file with our configuration parameters. The parts of the file you’ll want to change are as follows:

Enter your name and e-mail address in the ADMINS setting:

settings.py 1 Python

ADMINS = (
        # ('Your Name', 'your_email@domain.com'),
    )

Enter your database settings, using the database name, username, password, and host your chose in the Dreamhost administration panel.

settings.py 2 Python

DATABASE_ENGINE = 'mysql'           # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
    DATABASE_NAME = 'django_db'             # Or path to database file if using sqlite3.
    DATABASE_USER = 'jcroft'             # Not used with sqlite3.
    DATABASE_PASSWORD = '123qwe'         # Not used with sqlite3.
    DATABASE_HOST = 'djangodb.jeffcroft.com'             # Set to empty string for localhost. Not used with sqlite3.

Note: Django .96, which was released on March 23, 2007, requires MySQLdb 1.2.1p2. Many Dreamhost servers still have an older version. If you find that entering mysql as your DATABASE_ENGINE value throws an error, you will need to change it to mysql_old. This should be a temporary problem, fixed when Dreamhost upgrades MySQLdb, the Python module that providees connectivity to MySQL.

Edit your timezone:

settings.py 3 Python

# Local time zone for this installation. All choices can be found here:
    # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
    TIME_ZONE = 'America/Chicago'

Tell Django where your template directory is (we created it a while ago):

settings.py 4 Python

TEMPLATE_DIRS = (
        # Put strings here, like "/home/html/django_templates".
        # Always use forward slashes, even on Windows.
        "/home/jcroft/django/django_templates"
    )

Set the media root and media url to the media directory we created earlier:

settings.py 5 Python

MEDIA_ROOT = '/home/jcroft/django.jeffcroft.com/media/'
    MEDIA_URL = 'http://django.jeffcroft.com/media/'

Now, let’s edit your ~/.bash_profile file again, and add this line to the end of it:

.bash_profile Bash shell

export DJANGO_SETTINGS_MODULE=myproject.settings

  1. Then, active those changes by “sourcing the file”: source ~/.bash_profile
  2. Move into your project directory: cd ~/django/django_projects/myproject
  3. Syncronize your Django database with the changes you’ve made in the settings file. This process will also prompt you to create a “superuser” for your project: django-admin.py syncdb

Install and configure FastCGI

  1. Move into the directory for the subdomain you created way back at the begining: cd ~/django.jeffcroft.com
  2. Download the FastCGI Python script: wget http://svn.saddi.com/py-lib/trunk/fcgi.py
  3. Set the proper permissions on the script: chmod 755 fcgi.py
  4. Create a FastCGI Python script for your Django project. Make a new file called dispatch.fcgi and paste in these lines. Be sure to change the "jcroft" in the path to your username and the "myproject" to the name of your project, if you chose different name.

dispatch.fcgi Python

#!/usr/bin/env python
    import sys
    sys.path += ['/home/jcroft/django/django_src']
    sys.path += ['/home/jcroft/django/django_projects']
    from fcgi import WSGIServer
    from django.core.handlers.wsgi import WSGIHandler
    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
    WSGIServer(WSGIHandler()).run()

  1. Set the proper permissions on dispatch.fcgi: chmod 755 dispatch.fcgi

Set up mod_rewrite

Apache’s mod_rewrite module will pass all requests to your website through dispatch.fcgi, and thus, into Django’s URL dispatcher.

  1. Create a file called .htaccess (nte the leading dot) in your subdomain directory (for me, django.jeffcroft.com). Add the following lines to the file:

.htaccess Apache Configuration

RewriteEngine On
    RewriteBase /
    RewriteRule ^(media/.*)$ - [L]
    RewriteRule ^(admin_media/.*)$ - [L]
    RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
    RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

  1. Reset Python to activate all of our changes: pkill python

All URLs on our subdomain should now be routed to Django. Feel free to open up your browser and try it out for yourself.

Install Django’s built-in administrative interface

Django’s awesome admin tool is a Django program itself. As such, we’ll need to install it into this project, just like we would any Django app. Note that it’s entirely optional. However, it really is one of the nicest things about Django, so there’s a good chance you’ll want it.

  1. Link Django’s admin media files into our subdomain directory 9be sure to use your subdomain, instead of django.jeffcroft.com): ln -s $HOME/django/django_src/django/contrib/admin/media $HOME/django.jeffcroft.com/admin_media
  2. Set the admin media prefix in django/django_projects/myproject/settings.py:

settings.py 6 Python

ADMIN_MEDIA_PREFIX = '/admin_media/'

Add the admin application to your installed applications in django/django_projects/myproject/settings.py:

settings.py 7 Python

INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.admin',
    )

  1. Install the project with Django’s manage.py tool. You’ll need to be in your django/django_projects/myproject directory: python manage.py syncdb
  2. Uncomment the admin line in the URL configuration file (django/django_projects/myproject/urls.py):

urls.py Python

# Uncomment this for admin:
    (r'^admin/', include('django.contrib.admin.urls')),

  1. Reset Python again: pkill python

At this point, you should be able to go to http://django.yourdomain.com/admin and log into the Django administrative interface with the superuser username and password you created.

Now, you can get started making Django apps. From here, I highly recommend you head over to the tutorial on the official Django website. It’ll take you through build your first Django application. Note that we’ve already set up your first project, so you can skip the first section and head straight to “Creating Models.”

Update: Several months later, it was discovered that Dreamhost prefers the FastCGI script in this setup be called dispatch.fcgi. Previously, this article suggested django.fcgi. The article has been updated to reference dispatch.fcgi, but some comments blow refer to django.fcgi. Both filenames reference the same file.

Comments

  1. 001 // Joshua Blount // 05.12.2006 // 10:17 AM

    Wow, thanks for the great writeup, if you get a chance, or if any django wizards read this, what does it mean if I put in

    django-admin.py startproject myproject

    on my command line, and i get back the following:

    Traceback (most recent call last): File “/home/stickwithjosh/django/django_src/django/bin/django-admin.py”, line 2, in ? from django.core import management ImportError: No module named django.core

    ??? (newbies are the worst!)

  2. 002 // Jeff Croft // 05.12.2006 // 10:36 AM

    In short, that means it’s not finding the ~/django/django_src/core directory in your Python Path. Two questions:

    1. Did you add the lines to your .bash_profile in step two of “Download and set up Django?”
    2. Did you active those changes by sourcing the file (step three)?

    You might try logging out and back in again (another way to active the changes).

  3. 003 // Justin Perkins // 05.12.2006 // 10:44 AM

    Great guide for Dreamhosters, thank you Jeff.

    I followed the Dreamhost Django wiki a few months ago when you posted the series on templates (I don’t think that’s where they’re called, but your search seems down at the moment) and everything worked great, until I hit the point of trying to get the app running on Apache.

    Seems to be a common stumbling block for both Django and Rails. Is there another web server that works better than Apache (like Rails and Lighttpd)?

  4. 004 // Jeff Croft // 05.12.2006 // 10:51 AM

    @Justin: lighthttpd does work with Django, although I’ve not used it myself, so I can’t really speak to whether it works “better” or not.

    Re: Search problems: Actually, this whole site is a bit up and down right now due to another site on the server eating up all the PostgreSQL connections. Trying to get that resolved as we speak. :)

  5. 005 // blimmer // 05.12.2006 // 11:38 AM

    Many thanks for this, it was helpful to me. Added it to the dreamhost wiki under External Links too.

    Spread the love

  6. 006 // James Bennett // 05.12.2006 // 12:57 PM

    Justin: Django does work just fine with lighttpd, but so far as I know Dreamhost doesn’t provide any way of using that. If you’re interested, though, I wrote up a manual for Django/FCGI/lighttpd at TextDrive which you might be able to adapt to other hosts which do offer lighttpd as an option.

    (and don’t let the fact that it was written for Django 0.90 scare you off; aside from the fact that django-admin.py is now only used to start a project and manage.py does everything else, not much has changed in the server setup).

  7. 007 // Maura // 05.12.2006 // 1:18 PM

    At the beginning you say you’re going to use django.jeffcroft.com, then later on your switch to appsrv.jeffcroft.com. Am I missing something?

  8. 008 // Luke L // 05.12.2006 // 1:20 PM

    Hey Jeff, brilliant guide, been looking for a good introduction to actually getting set-up. So far I’ve gotten down to ‘ Download and set up Django’. I’ve completed part one, but I’m not sure what you mean at steps 2 and 3. PuTTY says it can’t find any .bash_profile in any directory and I don’t know where to create one otherwise. Please could you clarify just this little bit so I continue.

  9. 009 // Jeff Croft // 05.12.2006 // 1:21 PM

    Doh! Nice catch, Maura! It should be django.jeffcroft.ocm all the way through. I fixed it. :)

  10. 010 // Jeff Croft // 05.12.2006 // 1:25 PM

    Luke-

    The .bash_profile should be in your home directory. Since it’s a dot file (starts with a dot), it will be hidden by a standard “ls” command. Try “ls -a” and you should see it.

  11. 011 // Kevin Evans // 05.12.2006 // 1:42 PM

    Thanks for the instructions Jeff. I’ve been trying to get things working on Textdrive with lightty and fgci, with some success although the fcgi keeps randomly crashing, so I guess I’ll try Dreamhost next.

  12. 012 // Luke L // 05.12.2006 // 1:51 PM

    OK, I’ve made a .bash_profile, put those two lines in and uploaded it to django.mydomain.com, then i sourced it. No errors returned by PuTTY so I’m assuming it ran succesfully. However when I try the startproject bit it says it can’t find django-admin.py.

  13. 013 // Jeff Croft // 05.12.2006 // 1:59 PM

    Luke, it’s really hard to imagine why there wasn’t already a .bash_profile there. Very odd. I suspect you may not be looking in the right place. You say you uploaded it to django.mydomain.com. It should be in your $HOME directory, which is not the directory for your Django subdomain.

    When you first SSH into Dreamhost (using PuTTY, it sounds like), you’ll be dropped off in the directly that your .bashprofile should be in. It should already be there, and it should already contain a few lines. The two lines I’ve noted above need to be added to the existing .bashprofile.

  14. 014 // Luke L // 05.12.2006 // 2:28 PM

    OK, thanks Jeff. I really appreciate your patience. I’ve gone back to the beginning (deleted everything, resets etc). I added the lines to my .bashprofile (I found it exactly where you said it would be) and then sourced it. However I still get errors when trying to do the startproject part saying it can’t find django-admin.py! I have no idea what is wrong. Looking at my bashprofile after sourcing it, it still has $HOME etc, should these of been replaced with my actual home directory? Thanks again.

  15. 015 // Jeff Croft // 05.12.2006 // 2:32 PM

    Luke, the $HOME should be fine. You don’t need to replace that with your actual home directory.

    Could you maybe e-mail me a copy of your .bash_profile so I can make sure it looks correct (jeff@jeffcroft.com)?

  16. 016 // oliver // 05.12.2006 // 3:23 PM

    does anyone know a way to set up django with MAMP or is it impossible? i just don’t want to switch back to the os x built-in apache …

  17. 017 // Jeff Croft // 05.12.2006 // 3:33 PM

    Django should work fine on MAMP, if your definition of MAMP is Mac OS X, Apache, MySQL, and Python. Most of us at World Online have local development environments on our Macs (but we use PostgreSQL, not MySQL). There a lot of chatter about isntalling Django on Mac OS X in the commens of the Official Installation Documentation.

    I also found this.

  18. 018 // Vidar Masson // 05.14.2006 // 7:03 PM

    One small note, instead of “pkill python” it should be enough to say “touch django.fcgi” (with relevant path to django.fcgi of course). It seems a little less harsh than to kill it :) but its a matter of preference I suppose. Great guidelines by the way!

    Vidar

  19. 019 // Faruk AteÅŸ // 05.15.2006 // 5:19 AM

    Reset Python again: pkill python

    Hey Jeff, you may want to point out that the current issue with Dreamhost seems to be Python-caching. As such, if anyone using Dreamhost runs into changes in the code not having an effect on the output pages (admin or site), they need to run pkill python again.

    I’m currently having it pkill python any time I do syncdb because otherwise, it doesn’t work.

    Also note: if you do pkill, you are likely to get an error message from the server saying you don’t have permissions for that command; don’t worry, it still worked.

  20. 020 // Henrik Lied // 05.15.2006 // 9:17 AM

    Ok, I´m not quite sure if I´m getting this right:

    When I create the subdomain, should this point towards a web-accessible directory, or a home directory?

    The guide is great, Jeff, but I´d consider making it even more thorough. For people like me, I mean. :-)

  21. 021 // Jeff Croft // 05.15.2006 // 9:29 AM

    Vidar and Faruk: Great notes on pkill python. Thanks a lot! :)

    Henrik: The subdomain should point to a directory that will become the web-accessible directory for your new subdomain. The typical dreamhost setup is to make this directory name match the subdomain. So, in the example above, where my subdomain is called django.jeffcroft.com, I pointed it at a directory also called django.jeffcroft.com, which sits just inside my home directory.

    The reason I didn’t state this explicitly above is that this is the default behavior — if you do nothing else, you’ll get it right. But, you’re right — I should probably make it more clear.

    Good luck! :)

  22. 022 // Yas // 05.15.2006 // 10:39 AM

    Has anyone tried to set up Django on Media Temple?

  23. 023 // Peter Bowyer // 05.15.2006 // 1:06 PM

    If you want to see PostgreSQL at Dreamhost then do vote for it

  24. 024 // up0 // 05.15.2006 // 4:41 PM

    I’m also working on a django app on dreamhost and so far has been good with Apache and MySQL.

    I’m wishing of writing an install-script for dreamhost that would automate all this detail, though. I’ve plan for several django sites and it’d be a chore to setup each time.

  25. 025 // Bryant Cutler // 05.16.2006 // 1:24 AM

    I followed your instructions to the letter - substituting my own domain name, of course - and while these are MUCH easier to follow than those on the wiki, neither of them worked. FCGI works, as I can get the wiki’s little “Hello World” script to run just fun, but whenever I try to hit a django URL, I get HTTP500 Internal Server Errors about headers being 0 bytes long. I feel like I got conned into Dreamhost - I picked them because I’m low on cash and they were on the list of Django-supporting hosts… too bad I didn’t spend my money elsewhere and get and environment that works

    Just a warning, to anybody who wants to get reliable Django hosting…

  26. 026 // Jeff Croft // 05.16.2006 // 8:18 AM

    Bryant-

    Can you send me a copy of your django.fcgi script? Hard to imagine why you’d be getting the 0 byte header error. I’ll be happy to see if I can spot anything wrong with it…

  27. 027 // Simon7 // 05.18.2006 // 12:04 AM

    Work like a charm, thank you!

    —Simon

  28. 028 // Bryan Veloso // 05.18.2006 // 5:29 PM

    Yas-

    I’ve tried installing it on Media Temple, and succeeded in a way. Since I run a (dv) I’m trying to figure out how to get different installations to direct to different domains.

  29. 029 // Jeff Croft // 05.18.2006 // 5:34 PM

    Bryan-

    Depending on exactly what you want to do, you may not need multiple installations. One cool thing in Django is the ability to run multiple sites on one database and through one admin interface. For example, we have stories from multiple newspapers in one story database, and just use Django’s built-in “Site” parameter to select which site(s) a story is displayed on.

    If you’re doing two completely separate sites, you might want two installations. but, if your multiple sites are related, and/or are administered by the same person(s), it might be better to run them off one.

    Just depends on what you’re doing. :)

  30. 030 // Chris Wilson // 05.21.2006 // 8:34 AM

    Works great. Thanks so much.

    All you Dreamhosters be sure to cast your vote for default inclusion of Django under Home > Suggestions in the Dreamhost panel.

  31. 031 // Joshua Works // 05.21.2006 // 10:58 AM

    Jeff, any advice for getting docutils installed on Dreamhost? I wanna get to my custom documentation, but apparently I need root admin access to get it installed?? Did you manage to do this?

    I guess the larger issue is that I’m an idiot and can’t figure out how to get to my foreign key’d models from a template… but I’m getting there.

    Your write-ups have been indispensibe so far, so thanks!

  32. 032 // Jeff Croft // 05.21.2006 // 11:46 AM

    Joshua-

    I’ve not tried to get docutils installed.Would definitely be nice to have ‘em, though! The auto-documentation is a really great feature. I’m not sure off the top of my head if it would be possible to install them w/o root access or not, but I’ll see what I can find out.

    To get to your ForeignKey’d models from a template: If you have a Story model, and it has a foreign key to an Author model, which has fields for details about the author, you could do something like this in your template:

    {{ story.author.first_name }}
    {{ story.author.last_name }}
    

    For ManyToMany and OneToMany fields, Django gives you a “get_whatever” method on your model that returns a list object. So, you might have something like this:

    {% for tag in post.get_tags %}
        {{ tag.name }}
    {% endfor %}
    
  33. 033 // Kevin // 05.21.2006 // 4:47 PM

    IS the ‘post.get_tags’ tag stuff documented anywhere? I’m having a hard time getting that type of code to work on a ManyToMany.

  34. 034 // Jeff Croft // 05.21.2006 // 4:55 PM

    Kevin, try this: http://www.djangoproject.com/documentation/models/manytomany/

    Honestly, I may not have the syntax exactly right. I’m still mostly using Django pre-magic-removal merge which has a slightly different syntax.

  35. 035 // Kevin // 05.21.2006 // 5:13 PM

    Thanks Jeff, Found the answer..

    tags: {% for t in article.tags.all %}{{ t.title }}{% endfor %}

    in http://code.djangoproject.com/wiki/RemovingTheMagic

  36. 036 // Brian Sweeting // 05.26.2006 // 8:12 AM

    I’ve been trying to get django set up on dreamhost, but I haven’t been able to get it yet. I get a 500 error or the script just times out. I think fcgi is working, because I created a little hello.fcgi script that runs just fine. When I try running django.fcgi from the commandline, I am seeing errors in fcgi.py. I’m wondering if it has something to do with me having Python 2.3 instead of 2.4. When I run python -V, it returns Python 2.3.5. When I run whereis python it returns python: /usr/bin/python /usr/bin/python2.2 /usr/bin/python2.3 /usr/bin/python2.4 /usr/bin/python2.2-popy-config /etc/python2.2 /etc/python2.3 /etc/python2.4 /usr/lib/python2.2 /usr/lib/python2.3 /usr/lib/python2.4 /usr/local/lib/python2.2 /usr/local/lib/python2.3 /usr/local/lib/python2.4 /usr/include/python2.2 /usr/include/python2.3 /usr/include/python2.4 /usr/share/man/man1/python.1.gz. So I know that Python 2.4 is available but how do I specify that version over 2.3?

  37. 037 // Jeff Croft // 05.26.2006 // 8:48 AM

    Brian:

    Change the first line of django.fcgi to:

    #!/usr/bin/python2.4

  38. 038 // timc3 // 05.29.2006 // 3:21 PM

    Really nice article. Looking forward to getting my first django site working, and I second the earlier post about getting postgresql running on Dreamhost go click https://panel.dreamhost.com/index.cgi?tree=home.sugg&search=postgresql

  39. 039 // shmuel // 05.30.2006 // 12:01 AM

    Thank you so much for this article. I’ve nearly completed the setup process but seem to be hung up in a strange place. I installed the admin application exactly as directed and everything seems to be working fine except for the fact that it is not applying the css from /adminmedia/. I tried to access the file /adminmedia/css/login.css directly but it simply times out eventually giving me an internal error.

    Any ideas where I might have gone wrong?

  40. 040 // Jeff Croft // 05.30.2006 // 12:06 AM

    shmuel-

    Strange. it seems mostly likley that your problem is in your .htaccess file. It shouldn’t be running admin_media though django.fcgi, if it’s set up properly. What is the full error you’re seeing in your error logs?

  41. 041 // shmuel // 05.30.2006 // 12:11 AM

    My errror.log reads as follows:

    [Mon May 29 22:14:05 2006] [error] [client 69.214.2.91] FastCGI: comm with (dynamic) server “/home/shmuel/django.mysite.com/adminmedia/css/login.css” aborted: (first read) idle timeout (120 sec) [Mon May 29 22:14:05 2006] [error] [client 69.214.2.91] FastCGI: incomplete headers (0 bytes) received from server “/home/shmuel/django.mysite.com/adminmedia/css/login.css”

    My .htaccess looks like this:

    SetHandler fastcgi-script RewriteEngine On RewriteBase / RewriteRule ^(media/.)$ - [L] RewriteRule ^(admin_media/.)$ - [L] RewriteRule ^(django.fcgi/.)$ - [L] RewriteRule ^(.)$ django.fcgi/$1 [L]

  42. 042 // shmuel // 05.30.2006 // 12:13 AM

    Also: you might want to consider having Markdown enabled in your live comment preview (or at least mention that the Live preview isn’t really a preview). I kept trusting that was what my comment would look like only to have it ‘mangled’ by markdown.

  43. 043 // Jeff Croft // 05.30.2006 // 12:18 AM

    shmuel-

    Sorry about the markdown problem. No worries, though, as I could see your comment as you wrote it in the admin area.

    Your admin_media is definitely going through FastCGI when it shouldn’t be. I think the problem is the first line of your .htaccess. I don’t use a SetHandler line at all. Try removing that, and I think you’ll be okay.

  44. 044 // shmuel // 05.30.2006 // 12:36 AM

    That did it. I added that line at the recommendation of the Dreamhost wiki but removing it seems to be working.

  45. 045 // bret // 05.31.2006 // 4:41 PM

    I keep getting these errors:

    [Wed May 31 14:45:46 2006] [error] [client 129.xxx.xxx.xxx] FastCGI: incomplete headers (0 bytes) received from server ”/home/username/dj.bretw.com/django.fcgi”

    [Wed May 31 14:46:16 2006] [error] [client 129.xxx.xxx.xxx] FastCGI: comm with (dynamic) server “/home/username/dj.bretw.com/django.fcgi” aborted: (first read) idle timeout (120 sec)

    [Wed May 31 14:46:16 2006] [error] [client 129.xxx.xxx.xxx] FastCGI: incomplete headers (0 bytes) received from server ”/home/username/dj.bretw.com/django.fcgi”

  46. 046 // Jeff Croft // 05.31.2006 // 4:45 PM

    Bret-

    it sounds like there’s an error in your django.fcgi file. If you want to e-mail me a copy of it, I’ll be happy to take a look (jeff@jeffcroft.com).

  47. 047 // Tomas // 06.01.2006 // 3:02 PM

    I have done exactly like you have described, but it dosen’t work. I think the FastCGI is not working correctly (it is enabled in the webpanel). I have tried the hello.fcgi file (chmod to 755) and I only get a http 500 timeout error if I try to access it trough my browser. Any idea what could be wrong? I have sent a mail to support at Dreamhost and asked them if they could check the fastCGI.

  48. 048 // Keith // 06.01.2006 // 7:18 PM

    Thomas (and others having problems) — Have you been cutting and pasting Jeff’s code? If so you may note that depending on your text editor it’s not comming out correctly.

    If you havent yet, you might check that and make sure any single quotes, etc. are coming through correctly. Just an idea!

  49. 049 // Jeff Croft // 06.01.2006 // 9:03 PM

    Keith’s right. My SmartyPants filter (which converts straight quotes to curly ones, etc.) isn’t supposed to work on code samples, but it seems like it is doing it anyway. As such, copying can pasting can definitely get your funny quotes and other punctuation in your text editor. I’ll try to get this fixed, but in the mean time, be careful about copying and pasting. :)

  50. 050 // Tomas // 06.02.2006 // 3 AM

    I see. Does it work if I copy your code into notepad first? Or do I have to write the codes my self?

  51. 051 // Jeff Croft // 06.02.2006 // 8:45 AM

    Tomas-

    I’d recommend typing the “codes” yourself. You are welcome to try copying and pasting, but you are likely to run into problems.

  52. 052 // Tomas // 06.04.2006 // 5:15 AM

    Typing in the codes myself worked better. Now I get a django 404 error if I try to access django.mydomain.com. That’s suppose be that way, right?. I get the login screen (without css) on django.mydomain.com/admin , but when I try to login with the superuser, I get a 503 http error (Service Temporarily Unavailable).

  53. 053 // Jeff Croft // 06.04.2006 // 10:28 AM

    Tomas-

    Yes, sounds like you’ve got it installed properly now. Not sure why you’d get that 503, though. What’s the error in your error logs?

  54. 054 // Tomas Jacobsen // 06.04.2006 // 11:03 AM

    The logs in my django.mydomain.com ?

    [modsecurity: Access denied with code 503. Pattern match “(go.to|get.to|drop.to|hey.to|swit$ch.to|dive.to|move.to|again.at)” at HEADER. [hostname “django.mydomain.com”] [uri “/adminmedia/css/login.css”]

    Or is there another log?

  55. 055 // Jeff Croft // 06.04.2006 // 11:15 AM

    Okay, that’s not actually a Django error at all. That’s a modsecurity error when trying to access /adminmedia/css/login.css. The pattern match is a little bizzare. Do you have anything in your .htaccess besides what I suggested above? Did you create then soft link to your admin_media properly (step one under installing admin)?

    Basically, that’s saying it won’t let you access to css file in admin_media because of a security issue. My best guess is the soft link isn’t actually created properly so it’s trying to access a file other than the one it should be.

    But I’m really not sure. Never seen that before.

  56. 056 // Tomas Jacobsen // 06.04.2006 // 11:30 AM

    No, my .htaccess does not contain anything else. If I try to access my domain through ftp, I can see that “adminmedia” has a shortcut icon, but when I try to accesss it I get at “550 error: No such file or directory”. I have written ln -s $HOME/django/djangosrc/django/contrib/admin/media $HOME/django.mydomain.com/admin_media . All on the same line btw. Is there another way to make the shortcut?

  57. 057 // Leveille // 06.05.2006 // 12:49 PM

    Well, I went through this thing probably 3 times before I was able to get it to work. The first 2 times I copied/pasted example code into my text editor instead of typing the code myself. 3rd times a charm I guess.

    Thanks for the article Jeff. Time to roll up my sleeves and dig into Django. I can’t wait.

  58. 058 // Doug Nelson // 06.06.2006 // 8:02 PM

    Anyone have any ideas on how I could follow the instructions to the letter, then go to my site and just have it “Loading” forever? Dreamhost can be slow sometimes, but all my other subdomains are doing fine….

    Thanks in advance!

  59. 059 // Doug Nelson // 06.06.2006 // 8:07 PM

    cringe Nevermind. I missed one little step; changing jeffcroft to my doman name in django.fcgi.

  60. 060 // Mike Acton // 06.07.2006 // 1:22 AM

    I’m getting a 404 error when I try to put everything through django.fcgi in the .htaccess file; it says the django.fcgi file can’t be found. I can get it to go through on the command line, but that doesn’t really help. Any suggestions? (Everything’s pretty much line-for-line from the tutorial.)

  61. 061 // Jeff Croft // 06.07.2006 // 1:30 AM

    You get a 404 saying django.fcgi can’t be found? That doesn’t seem right at all. Sounds like something deeper isn’t set up correctly. If it can’t find your django.fcgi, you should actually get a 403, I believe.

    What directory is your django.fcgi in? You do have FastCGI enabled on the server, right?

    Off the top of my head, I’m not sure what might be causing that — might be one of those I’d have to see to understand. Can you post the error you’re getting in your error log?

  62. 062 // Mike Acton // 06.07.2006 // 2:16 PM

    Hah, I’m a moron. I even went to the web panel and checked the box to turn fastcgi on, but I never hit submit. That’s what 15 tabbed windows will do to you at 2:30am.

  63. 063 // kaktusz // 06.07.2006 // 8:23 PM

    python manage.py syncdb

    Error: Your action, ‘syncdb’, was invalid.

    Run “manage.py —help” for help.

    please help me!!! drop an email… I am blocked here.. already spent some hours;:)

  64. 064 // Jeff Croft // 06.07.2006 // 9:03 PM

    Ack. My mistake. That should be django-admin.py, not python manage.py. Like this:

    django-admin.py syncdb

    Sorry about that. I fixed it above. :)

  65. 065 // Tomas Jacobsen // 06.08.2006 // 4:30 AM

    The 503 error I got seems to be a dreamhost error. I made a new subdomain (django2.mydomain.com) and now it works!

  66. 066 // Scott McCracken // 06.13.2006 // 4:12 PM

    Jeff, I’d like to echo all the thanks for setting up such an amazing and detailed tutorial.

    I was wondering if you could shed some light on how you installed markdown on dreamhost. I have downloaded the python version of markdown from http://www.freewisdom.org/projects/python-markdown (both the soure file and setup.py) and placed them in my root directory on dreamhost.

    However, when I run the command ‘python setup.py install’ I get a permission error when the install script tries to copy markdown.py to my python directory:

    error: /usr/lib/python2.3/site-packages/markdown.py: Permission denied

    I know you’re a busy guy, but if you have any insights on this problem it would be much appreciated. Also is there a python version of smartypants? Thanks!

  67. 067 // Jeff Croft // 06.13.2006 // 4:26 PM

    Scott-

    Basically, you just want to put the markdown.py file anywhere in your Python path. The simplest way is to just drop markdown.py in your djangoprojects directory. A slighty more complicated, but cleaner way (and actually the way I did it) is to create another directory for Python modules like this. I created a directory at the root of my Dreamhost account called “pylib”. You then need to add this directory to your python path by adjusting .bashrc and django.fcgi accordingly. If that makes sense, go for it. If not, just drop markdown.py in your djangoprojects — that’ll work fine.

    You won’t be able to run the setup.py install command on most Python modules on Dreamhost, because you don’t have permission to install server-wide packages.

    As for SmartyPants — there is a Python port. I’ve found it to be not quite as perfect as the original Perl version, but it basically works. Just Google for it. You’d install it the same way (drop smartypants.py in your Python path).

  68. 068 // dana // 06.19.2006 // 6:33 PM

    Jeff-

    Thanks for the amazingly detailed tutorial, I actually managed to get everything up and running. I have two questions though, first I can’t seem to get that smartypants filter to work… I just dropped it in my projects folder along with markdown (which works just fine) but when I do {{ entry.body|smartypants }} Django complains “Invalid filter: ‘smartypants’… any suggestions?

    Also you mention that you spent most of your time working with python importers for ma.gnolia and flickr and the like… any chance you’d be willing to share how that process worked? Not asking you to give away your code or anything, I’m more interested in understand what you did than how you did it. Is that a whole sperate app or did you pull that stuff straight into your blog app? Or forget what you did, how would you suggest a django newbie appraoch such a task?

    thanks again for taking the time to help the rest of us out.

    cheers

  69. 069 // Jeff Croft // 06.19.2006 // 7:18 PM

    Dana-

    Thanks, I’m glad the tutorial was useful!

    Re: SmartyPants. The “markup” template tag that is included with Django doesn’t support SmartyPants by default. It handles Markdown, Textile, and restructured text. I hacked the markup template tag to include SmartyPants support. In hindsight, a better option would have been to write my own template tag for SmartyPants — because now I stand to have my changes overwritten when I upgrade Django. Writing a tempalte tag for Django is incredibly easy. You can do the SmartyPants one in four or five lines of code. I’d suggest looking at the markup filter that comes with Django (django_src/django/contrib/markup/templatetags/markup.py). It’s pretty straightforward — I’ll bet you can figure it out. :)

    As for the importers: basically, I’ve just got Python scripts (some that I wrote, and some that Jacob wrote) that query the open APIs of various services (flickr, ma.nolia, last.fm, etc.) and then use Django’s database API to save items into the database. I actually would be more than happy to release the ones I wrote if they were based on the newer, magic-removal Django syntax — but they’re not. I fear that releasing anything based on old Django syntax into the public is just asking to cause confusion. The importers are pretty simple to write if you know your way around Python and you’ve read the Django database API documentation. If not, I’d suggest you enlist your nearest Python programmer to help you along the way. :)

    One note: the Python API kit available at flickr.com seems really nice. I didn’t use it, but in hindsight I probably would have. It seems much nicer than what I hacked up.

  70. 070 // Thomas Ashelford // 06.20.2006 // 8:43 AM

    I’ve been running a number of Django installations on DreamHost for a few months now without too much drama, but suddenly yesterday one of them died for no apparent reason (the code hadn’t tweaked for a few days). We’re now getting the following error log:

    [Sun Jun 18 23:34:49 2006] [alert] [client 210.0.78.197] (2)No such file or directory: FastCGI: failed to connect to (dynamic) server “/home/lafa/lafa.dreamhosters.com/django.fcgi”: something is seriously wrong, any chance the socket/named_pipe directory was removed?, see the FastCgiIpcDir directive

    Does anyone out there have any ideas? This sort of flakiness has me looking for a new host.

  71. 071 // cwg // 06.20.2006 // 3:13 PM

    I’d like by Django apps to authenticate off of my own LDAP server that is already running. Can I authenticate off of an external LDAP server if I host my Django app on DreamHost?

  72. 072 // Jeff Croft // 06.20.2006 // 3:29 PM

    cwg-

    There is a Django branch called multi-auth. You can find it at the Django website. I’ve not used it, so I don’t know exactly what it offers, but I believe LDAP auth is part of it.

    From talk I’ve overheard, I think it’s very likely the multi-auth bits will be merged into trunk sometime in the near future — but don’t quote me on that.

  73. 073 // Kevin // 06.20.2006 // 3:43 PM

    nb. fcgi support via manage.py is new to the trunk version of Django, see initial documentation

  74. 074 // Kevin // 06.21.2006 // 2:46 PM

    re: importer scripts

    I had a go at a Flickr version for latest Django here. Now for Magnolia..

  75. 075 // redg // 07.09.2006 // 5:46 AM

    very nice simplification of heavy tech stuff!

    I hope i can get it to work, it really looks like a new world is opening with django. However i can’ t swing it past point 3 from “Download and Set-up”. I tried it 2 times with a clean install on a different subdirectory on dreamhost. I keep running into this error after i source the bash_profile (: octal number out of range). I don’t feel like giving up yet, but maybe a litle help is needed. I hope anyone can spare a moment in helping me out. tnx in advance.

    redg

  76. 076 // redg // 07.11.2006 // 4:19 AM

    looks like i solved my problem mentioned above by editing the .bash_profile with putty instead of downloading, editing in notepad and uploading again

    command to edit in putty: pico -w .bash_profile

    just in case anybody wondered :)

  77. 077 // kayzzer // 07.16.2006 // 9:02 AM

    Jeff, your tutorial is incredible, this days people don’t take the time to write such a good article, they are more interested in scatter a lame tutorial into the biger number of pages so they can get more clicks from the needed and desperate newbee like my.

    It’s nice to see that we still have heros like you. I try to configure my django site on dreamhost following the wiki instructions and it was a nigtmare ( mostly because they take too much for granted ) not because it’s a bad guide. And just FYI I got into dreamhost mainlly because they are django friendly.

    Then I found this page and finally got my site up and runing with no problem.

    Thank you Jeff.

  78. 078 // Benton Pena // 07.24.2006 // 5:26 PM

    Thanks so much for this tutorial, I got my django up and running without a problem.

    Thanks, regards

    Benton

  79. 079 // Chris // 07.30.2006 // 10:09 PM

    I am having a the same problem a few other people are haveing. I keep getting: command not found, : octal number out of range, : command not found, when I do a source on the bash_profile.

  80. 080 // Chris // 07.30.2006 // 10:34 PM

    Well i am no longer getting the octal number out of range error. So I went to the next step and starting a new django project and from django-admin.py startproject myproject I get an error: django-admin.py: command not found. Any suggestions?

  81. 081 // Jeff Croft // 07.30.2006 // 10:40 PM

    Chris-

    If django-admin.py cannot be found, it is because the directory that contains it (~/django/django_src/django/bin if you used the directions here exactly) is not in your $PATH.

    You’ll want to make sure the following line is in your .bash_profile:

    export PATH=$PATH:$HOME/django/django_src/django/bin`
    

    Also, make sure you’re dealing with the file .bash_profile in your hoe directory -- note the dot that starts the file name. You said bash_profile earlier (no dot), so just wanted to make sure. :)

  82. 082 // Chris // 08.02.2006 // 10:19 PM

    I figured out my problem. I installed django in the wrong directory. I got through all the steps and I am having a problem Brian Sweeting stated above. I am getting a 500 server error. I tried changing my first line of django.fcgi to #!/usr/bin/python2.4 and still get the same error. Then I went back and maid sure I typed all the code instead of copy and pasting but still the same thing. Any ideas?

  83. 083 // Brad // 08.04.2006 // 10:02 AM

    I’ve been trying to set up Django on dreamhost for about two weeks now but just cannot for the life of me get past this whole .bashprofile thing. I’ve followed your steps to the T but all I get when I try to source the .bashprofile is “Bad : modifier in $ ($).”

    I copy and pasted everything so I’m not sure what’s going on.

  84. 084 // Jeff Croft // 08.04.2006 // 10:12 AM

    Brad, it sounds like there’s a syntax error in your .bash_profile. Can you send me the file in e-mail (jeff@jeffcroft.com) and I’ll see if I can spot it?

    Thanks.

  85. 085 // Brad // 08.04.2006 // 3:03 PM

    Email sent! I don’t know what is up. Maybe I am missing something else in my .bash_profile because I just straight copied and pasted from your tutorial.

  86. 086 // Sam // 08.07.2006 // 2:18 AM

    Thanks for the great tutorial, I’d have been sunk without it. I have one question, however. I’m making a second project, and am wondering what my .bashprofile should look like. I now have project1.myurl.com and project2.myurl.com should the last two lines of my .bashprofile be:

    export DJANGOSETTINGSMODULE=project1.settings export DJANGOSETTINGSMODULE=project2.settings

    ? Or is this incorrect? If so what should it look like? Thanks.

  87. 087 // Jeff Croft // 08.07.2006 // 2:23 AM

    Sam-

    I’m afraid you can’t have your DJANGOSETTINGSMODULE set to two different things at the same time. The best way around this little problem is django’s built-in manage.py script, which you’ll find in each project directory.

    You can use manage.py for almost anything you can use django-admin.py for, except that manage.py automatically uses the settings of the project for the directory you’re currently in.

    So, if you’re DJANGOSETTINGSMODULE is set to project1.settings and you need to do something (say, syncdb) on project2, you could do something like this:

    cd django/django_projects/project2
    python manage.py syncdb
    

    In short, django-admin.py will take it’s settings from your DJANGOSETTINGSMODULE and manage.py will take them from the directory you’re in.

  88. 088 // Adam Blinkinsop // 08.07.2006 // 5:49 PM

    Jeff - just wanted you to know that this is a great tutorial. Had no problems setting my site up.

    For any developers reading this: you might want to change his directory names from ~/django/django_src to ~/django/src, and so on. I also store my site in Subversion (included with Dreamhost) so I can save changes and things. If you can’t figure the second part out, contact me.

  89. 089 // kakei // 08.08.2006 // 1:11 AM

    Hello Jeff great post, but actually i got the same problem of Adam when i reload the source i get

    PS1=[\u@\h \W]\$ : Command not found. Bad : modifier in $ ($).

    actually my .bash_profile looks like this :

    umask 002 PS1=’[\u@\h \W]\$ ’

    export PATH=$PATH:$HOME/django/djangosrc/django/bin` export PYTHONPATH=$PYTHONPATH:$HOME/django/djangosrc:$HOME/django/django_projects

  90. 090 // George // 08.08.2006 // 1:11 PM

    Hi,

    I wrote a small app, and wanted to host on dreamhost. I tried every trick I know, and followed your code and example to the ditto. Expect for following

    I put django_src on my Home folder. /home/username, but wherever this had to be referred, I have done exactly what was required, in setting the right paths.

    Django-admin is working. I am able to create models and whatever is required to be created.

    However FCGI is not working. I have set it in the dreamhost panel. The site seems to be connecting, but it is throwing 500 errors.

    Even the admin module is not working

    I wrote the hello.fcgi script from the dreamhost wiki, and that also is not working.

    I have ‘pkill’ ed python number of times, that ,may be the snake is dead by now.

    Appreciate your suggestions

    George

  91. 091 // can xiang // 08.22.2006 // 5:10 AM

    Thanks Jeff, it’s a great tutorial to follow. I’ve finally set up my dreamhost site with Python2.4 and domain transfer

    Here is some thing to note for newbie like me:

    1. Set #!/usr/bin/python2.4 if you need python2.4 django.fcgi is the place to set your python version for the FCGI process, no, not .bash_profile.

    2. You’d better create python directory In the tutorial, fcgi.py is placed in your domain directory. I’d suggest you create your own directory to hold python libraries because you’ll find dreamhost can’t provide all you need soon or late. For example: /home/username/lib/python2.4/site-packages

    3. Set the python path in django.fcgi You may want to use libraries not shipped with dreamhost, put them in the directory we created in point 2 and add your: sys.path+=[‘/home/username/lib/python2.4/site-packages’]

    4. Transfer your domain to DH You may want DH serve your domain while the domain is registered with other registrar. You can just leave A record empty and set NS to ns1.dreamhost.com and ns2,.. to your original registrar. Do anything you want with DH then…

    5. You domain takes time to work after change If you made a configuration change in DH, you’d better have a cup of coffee than watching the screen and fighting with the server not reachable error.

    6. 500 Error doesn’t really mean error If you tried everything you can and still get 500 error(0 bytes error), you may just “WAIT” for a couple of minutes. The FCGI process seems take time to go alive after received request from browser.

    Some part of this comment may off topic, sorry for that. I know someone must want to get answer in one place, let’s make it django place.

    can

  92. 092 // Jeff Croft // 08.22.2006 // 8:57 AM

    Set #!/usr/bin/python2.4 if you need python2.4 django.fcgi is the place to set your python version for the FCGI process, no, not .bash_profile.

    You’ll probably want to add an alias in -bash_profile, too, or your command line utilities (django-admin.py and manage.py) won’t be using Python 2.4.

  93. 093 // can xiang // 08.22.2006 // 7:24 PM

    Jeff,you are right, setting python2.4 in .bash_profile for command line but not for FCGI script.

  94. 094 // Spirit // 08.24.2006 // 12:37 PM

    Oh noes! That link is down: http://www.saddi.com/software/py-lib/py-lib/

    Google cache seems to have it though. http://66.249.93.104/search?q=cache:KQ2j2vCZdC8J:svn.saddi.com/py-lib/trunk/fcgi.py+fcgi.py&hl=de&gl=de&ct=clnk&cd=2

  95. 095 // Jeff // 08.25.2006 // 1:42 PM

    In order to get an official release from Subversion:

    svn co http://code.djangoproject.com/svn/django/tags/releases/0.95 django_src

  96. 096 // Jeff // 08.25.2006 // 2:49 PM

    Doodie.

    Every step has completed successfully so far and I’ve double-checked everything :(

    I’m failing with a ‘500’ error and an infinite hourglass cursor. I have changed django.fcgi to use /usr/bin/python2.4 as recommended above…

    Doesn’t help.

    Info is all here, instead of me posting this much in a comment:

    http://www.kickflop.net/temp/django.txt

    If anyone has any ideas, I’m all ears.

    Thanks for the write-up, Jeff.

  97. 097 // Jeff // 08.25.2006 // 3:37 PM

    Sorry for the spam. It’s fixed. My django.fcgi still had ‘myprojects.settings’ in it instead of my actual project name.

  98. 098 // Benjamin Chait // 08.30.2006 // 2:21 AM

    I’m curious if anyone has attempted to install Django on a (mt) Media Temple Shared Server solution…?

    Thanks in advance!

  99. 099 // Jason Nolen // 09.03.2006 // 12:09 AM

    Jeff- Tutorial is great…I’m pretty close. I know my django is communicating with mySQL because I have done the tutorial on djangoproject’s site w/o problems. However, when trying to access django.gigfriend.com (my subdomain), I get an 500 Internal Server error. I’ve read the posts above on this subject, have re-entered all code by hand, no copy/pasting, added the #!usr/bin/python2.4 line to my django.fcgi (that’s in fact where it is), so I’m out of ideas. Thanks.

  100. 100 // Jason Nolen // 09.03.2006 // 12:12 AM

    re:my last post - I’m actually trying to load django.gigfriend.com/admin and that is what is producing the 500 internal server error. I’ve set up the admin tool to the dot of the above instructions…help?

  101. 101 // Chris // 09.07.2006 // 9:12 PM

    I finally got back to trying to install django and found out it was fastCGI not running even when it was selected in my domain setup. For othere people having the same 500 error you might want to contact dreamhost and check into seeing if fastCGI is working properly.

    Now when I type in my url I get an error though. Is this suppose to happen? Here is the error:

    Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order: ^admin/ The current URL, /, didn’t match any of these.

  102. 102 // Jeff Croft // 09.07.2006 // 9:18 PM

    Now when I type in my url I get an error though. Is this suppose to happen?

    Yep, that’s exactly what is supposed to happen. That’s telling you there is no Django view configured to respond to requests for the URL “/”. There is, though, a view (that admin interface), configured at ”/admin”.

  103. 103 // Trey Piepmeier // 09.08.2006 // 12:18 AM

    If you’re having trouble with .bash_profile giving you the error

    Bad : modifier in $ ($)

    make sure you’re running BASH as your shell. Type ps and you should see something like:

    12345 pts/2 00:00:00 bash

    If not, go into your control panel under “Users >Manage Users”, then edit your shell user and select /bin/bash.

  104. 104 // Chris // 09.08.2006 // 9:32 PM

    That’s awesome. I sure was hoping I was seeing things correctly. Thanks Jeff for all the help and incredible step by step process.

  105. 105 // Tom // 09.12.2006 // 8:27 AM

    Any thoughts on this flup approach to FastCGI as suggested by the Dreamhost wiki?

  106. 106 // boneskull // 09.13.2006 // 4:18 AM

    To everyone with the “FastCGI: incomplete headers” error:

    this is the contents of my .htaccess file which makes things go:

    DirectoryIndex django.fcgi

    RewriteEngine On

    RewriteBase /

    RewriteRule ^(media/.*)$ - [L]

    RewriteRule ^(admin_media/.*)$ - [L]

    RewriteRule ^(django.fcgi/.*)$ - [L]

    RewriteRule ^(.*)$ django.fcgi/$1 [L]

  107. 107 // John McCaine // 09.18.2006 // 1:55 PM

    Having difficulty with displaying the admin. The following message turns up:

    /home/username/django/djangosrc/django/core/urlresolvers.py in _geturlconf_module, line 173

    Thank you

  108. 108 // Brad // 09.26.2006 // 12:49 PM

    Yeah…my admin page won’t show either. I just get this:

    Page not found (404) Request Method: GET Request URL: http://djangocms.infinitivestudios.com/internal_error.html

    Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order:

    1. ^admin/

    The current URL, /internal_error.html, didn’t match any of these.

    You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

  109. 109 // Phil Leitch // 10.16.2006 // 8:07 AM

    First of all, thanks for the great walkthrough of setting Django up on Dreamhost.

    Through trial and error and mostly a lot of mistypings I think I just about have it, other than the admin.

    When I go to /admin I get a 404. Should I be seeing an admin looking screen or is this right? hmmm, same thing as the previous poster I guess.

    thnx.

  110. 110 // dale // 10.22.2006 // 9:58 PM

    Phil L. - I was having the same problem as you where my admin login would not show up. I tried what Brad mentioned and in my settings.py file, i changed “DEBUG = True” to “DEBUG = False”. Now when I try going to “django.mysite.com” i get a python error page saying the template doesn’t exist. But if you go to “django.mysite.com/admin”, the login appears and works with your superuser information.

  111. 111 // dale // 10.23.2006 // 11:10 PM

    From my last statement, I changed the settings.py file in ‘mysite’ directory back to “DEBUG = True”, and am still getting a python error page ‘TemplateDoesNotExist’ in my django.mysite.com. (but django.mysite.com/admin still works) I was looking at the sitepoint tutorial and according to that, I should be getting some sort of congratulations page saying something along the lines of “you have your first django page”. Any clue what I might have done to not get that page?

  112. 112 // Robson Junior // 10.24.2006 // 10:36 PM

    Hello Jeff, I’ve been trying to get django set up on dreamhost, but I haven’t been able to get it yet. I get this problem. Can u help me?

    Traceback (most recent call last): File “/home/kimmaydesign/resources/flupsrc/flup/server/fcgibase.py”, line 558, in run protocolStatus, appStatus = self.server.handler(self) File “/home/kimmaydesign/resources/flupsrc/flup/server/fcgibase.py”, line 1112, in handler result = self.application(environ, startresponse) File “/home/kimmaydesign/resources/djangosrc/django/core/handlers/wsgi.py”, line 185, in call response = self.getresponse(request) File “/home/kimmaydesign/resources/djangosrc/django/core/handlers/base.py”, line 59, in getresponse response = middlewaremethod(request) File “/home/kimmaydesign/resources/djangosrc/django/middleware/common.py”, line 41, in processrequest if settings.APPENDSLASH and (oldurl[1][-1] != ‘/’) and (‘.’ not in old_url[1].split(‘/’)[-1]): IndexError: string index out of range

  113. 113 // Baxter // 10.25.2006 // 4:37 PM

    Dale, it’s telling you the problem. Whatever template you’re pointing to for django.mysite.com doesn’t exist. Look in URLS.py and see what and where it should be.

    Robson, your problem is out of my depth, but something tells me it’s an htaccess or django.fcgi thing. Of course, it would help if I knew where you were in the process when you got that.

  114. 114 // Eric Smith // 11.01.2006 // 4:10 AM

    I’ve just found this interesting post on Dreamhost Discussion Forum: http://tinyurl.com/ykbl2p

  115. 115 // David Comdico // 11.02.2006 // 5:53 PM

    For those of you having problems receiving a 500 timeout error: I received them the first time I went through this tutorial, when I copied and pasted from the browser.

    The second time through I typed everything in with pico, and it worked like a charm.

  116. 116 // Mike Clowe // 11.08.2006 // 12:41 AM

    Jeff,

    Thanks for the great tutorial. Its helped a ton.

    One question:

    The css does not seem to be rendering for the admin inteface. My .htaccess does not use sethandler. Any ideas why this is?

  117. 117 // Donald // 11.11.2006 // 3:03 AM

    Hey, thanks for putting so much attention to detail in this writeup. It is much appreciated.

    However, I’m experiencing a snag; after the Set up mod_rewrite step, URLs using my django subdomain aren’t redirected and do what they would normally do. For instance, http://django.anzidesign.com shows a directory listing. Non-existing URLs under that subdomain show the standard 404 page.

  118. 118 // Marc // 11.16.2006 // 4:18 PM

    Very nice tutorial! Worked like a charm for me. I’m pretty impressed with Django so far. Thanks!

  119. 119 // Ulysses // 11.21.2006 // 7:54 PM

    found fcgi.py here

    http://svn.saddi.com/py-lib/trunk/fcgi.py

  120. 120 // Karl Peterson // 11.28.2006 // 4:46 PM

    Thanks a lot for the quick email reply and this tutorial. I switched over to DreamHost and got django installed in a day! I’ve never really worked with command line stuff and this has been a really excellent learning experience.

  121. 121 // Andy Baker // 12.03.2006 // 8:39 AM

    The path I had to put in django.fcgi was for some reason actually:

    /home/.pay/andy/django_src

    I spent days trying to find the problem and it wasn’t until I ran a Python script to print os.getcwd() to my browser did I find the problem. From the shell pwd told me it was simply /home/andy/

  122. 122 // Michael Hessling // 12.07.2006 // 8:17 PM

    Took me a while to get it installed. I ran the gamut of every error described in the comments, but my constant misspellings of djagno django was the ultimate problem.

    Thank you, Jeff.

  123. 123 // Joe W. // 12.26.2006 // 8:20 PM

    Thanks for the tutorial. One note: you’ve updated the .fcgi filename to be dispatch.fcgi, but last two lines in the .htaccess don’t match that fact.

  124. 124 // Jeff Croft // 12.26.2006 // 8:55 PM

    Whoops! Thanks, Joe! I’ll fix that now… :)

  125. 125 // Paul Downey // 01.03.2007 // 12:08 PM

    great guide!

    I dod have to add the following to .htaccess and avoid timeout/500 errors:

    AddHandler fastcgi-script .fcgi Options +FollowSymLinks +ExecCGI

  126. 126 // Darian // 01.03.2007 // 10:50 PM

    Great tutorial.

    Noticed one thing, the link for fcgi.py is broken. I had to grab it from here

  127. 127 // Brian // 01.08.2007 // 9:58 AM

    Thanks for the tutorial Jeff, got me up and running in no time. One question, once I have everything set up at django.mydomain.com, how would I serve a blog from mydomain.com? Basically, all the django stuff is under that django subdomain, but I am wanting to use django on the actual domain.

  128. 128 // Jeff Croft // 01.08.2007 // 11:26 AM

    Brian, that’s a good question that I probably should have covered in the post! Basically, the steps would be:

    1. Configure the Dreamhost panel options for main domain with the same settings as the django one (FCGI support, etc.).
    2. Copy the files that are in your django.mydomain.com directory to the domain.com directory (including the .htaccess).
    3. Change the references in settings.py to django.mydomain.com to just mydomain.com.

    That should pretty much cover it. Once you verify it’s working, you can delete the django.mydomain.com from the Dreamhost panel, if you want.

  129. 129 // dale // 01.09.2007 // 1:02 AM

    i keep on getting this error

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete. after trying to go to my subdomain

    http://django.whatthedale.com/

    and is redirecting to

    http://django.whatthedale.com/$l

    i’m assuming the “$l” is coming from .htaccess file in my subdomain? does anyone know why it’s not resolving and getting a timeout error?

  130. 130 // Brian // 01.09.2007 // 9:45 AM

    Hey Dale,

    Sounds to me like a syntax error in your .htaccess. Copy the text of your .htaccess file and post it, I might be able to spot the error.

  131. 131 // BrianZ // 01.14.2007 // 11:58 AM

    This is a great tutorial…thanks Jeff.

    Sadly, I cannot for the life of me get django running. I’m plauged by 500 errors which I think are all go back to FastCGI. The simple hello.fcgi program from the wiki doesn’t even work (I’ve tried renaming is dispatch.fcgi too). My log file has the incomplete headers error which, from what I’ve been reading, is sympomatic of the processes being killed.

    When I run hello.fcgi from the command line it works fine.

    Does anyone have tips? BTW, I’m on the snapple DH machine.

  132. 132 // dale // 01.14.2007 // 12:56 PM

    here’s what i have in my .htaccess file:

    RewriteEngine On RewriteBase / RewriteRule ^(media/.)$ - [L] RewriteRule ^(admin_media/.)$ - [L] RewriteRule ^(dispatch.fcgi/.)$ - [L] RewriteRule ^(.)$ dispatch.fcgi/$l [L]

    thanks.

  133. 133 // Brad // 01.29.2007 // 10:53 PM

    Sadly, I had django set up on my dreamhost account and then did something to crash it…got frustrated…deleted it and thought I’d just start over. But now I can’t get it running for the life of me. I’m 99% sure it has to do with the FastCGI but I’m completely lost. Like ‘BrianZ’ I can’t even get hello.fcgi to load. Nothing but ‘incomplete header’ errors here. Anyone willing to lend a hand feel free to e-mail me ( brad at spyderfcs.com) because it would be greatly appreciated. I have such a great deal with dreamhost (225GB storage and 2048GB bandwidth) that I would hate to leave them but I really am getting into some django development on my machine and I’m loving it!

  134. 134 // Ford // 03.02.2007 // 12:10 AM

    Worked great except for one thing - Dreamhost appears to be using Python 2.3.5, which lacks the str.rsplit method (a part of Django now apparently)

    To prevent the following error: File "/home/snosrap/dev/django/django_src/django/core/management.py", line 1358, in load_data fixture_name, format = fixture_label.rsplit('.', 1) AttributeError: 'str' object has no attribute 'rsplit'

    I had to make the following change:

    fixture_name, format = rsplitx1(fixture_label) #fixture_name, format = fixture_label.rsplit('.', 1)

    and elsewhere def rsplitx1(s, c='.'): try: i = s.rindex(c) return s[:i], s[i+1:] except ValueError: return s

  135. 135 // Jeff Croft // 03.02.2007 // 12:36 AM

    Hmm, interesting. I don’t think Django is supposed to require Python 2.4.

    Anyway, the much easier way around this would be to simply use Python 2.4, which is also available on Dreamhost.

  136. 136 // James Greig // 03.18.2007 // 3:36 PM

    You must have invested a lot of time in creating this tutorial, nice work Jeff!

    I’m very close to completing my install, but am stuck right at the end:

    [patton]$ python manage.py install admin
    Error: Your action, 'install', was invalid.
    

    I also seem to be getting the dreaded error 500 message, even when running my hello.fcgi file.

    [Sun Mar 18 13:00:51 2007] [error] [client 82.152.174.245] FastCGI:
    incomplete headers (0 bytes) received from server
    "/home/jamesgreig/django.3stripe.net/hello.fcgi"
    

    Can anyone help me out?

  137. 137 // James Greig // 03.19.2007 // 5:28 PM

    Well, I got this working on my local (Mac) machine today. I’m thinking Dreamhost is not really the most stable of places to play with Django.

  138. 138 // Jeff Croft // 03.23.2007 // 8:48 PM

    James-

    My apologies. The install command has been removed from the manage.py script in the most recent versions of Django. Instead, you want to do python manage.py syncdb. I've updated the tutorial to reflect this.

  139. 139 // ehh // 03.24.2007 // 7:13 PM

    You should also write about MySQL engine, because DH use old one so in settings.py should be DATABASE_ENGINE = ‘mysql_old’

  140. 140 // Marek Ryćko // 03.24.2007 // 7:17 PM

    Thank you, Jeff, for the great article.

    It is probably worth to notice, that at the present moment, after the step “Set up mod_rewrite” the result displayed in the browser (In some cases? In all cases?) is “Internal Server Error”. This is due to the current initial settings of memory limit in the instance of Apache that runs the new domain or subdomain at Dreamhost.

    The only solution (until something changes) is to contact the Dreamhost Support team (through the Support / Contact Support in the Control Panel) and ask them to raise the Apache memeory limit for a particular domain or subdomain or for a few domains (probably mentioning that it is for the installation of Django). They are very helpful and respond within one to few hours, probably depending on the emergency level set at the bottom of the “contact support” form.

    After raising the Apache memory limit everything works great.

    I selected for the installation the sqlite3 database and it works fine.

    Once again thank you, Jeff, for this article and for all your articles.

  141. 141 // Jeff Croft // 03.25.2007 // 11:05 AM

    @ehh: This is a temporary problem that only applies to (the ju