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.
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.
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:
django.jeffcroft.com and will be using that name in this tutorial.
We’ll also need to setup a MySQL database to use with Django (sadly, Dreamhost doesn’t support PostgreSQL). Follow these steps:
django_db and will be using that name in the tutorial.
djangodb.jeffcroft.com.
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.
mkdir django
cd django
mkdir django_templates and mkdir django_projects
mkdir ~/django.jeffcroft.com/media
We’ll be using the latest Django by checking it out from its Subversion repository.
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
export PATH=$PATH:$HOME/django/django_src/django/bin
export PYTHONPATH=$PYTHONPATH:$HOME/django/django_src:$HOME/django/django_projects
source ~/.bash_profile
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.
cd ~/django/django_projects
django-admin.py startproject myproject
chmod 600 myproject/settings.py
Enter your name and e-mail address in the ADMINS setting:
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.
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:
# 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):
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:
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:
export DJANGO_SETTINGS_MODULE=myproject.settings
source ~/.bash_profile
cd ~/django/django_projects/myproject
django-admin.py syncdb
cd ~/django.jeffcroft.com
wget http://svn.saddi.com/py-lib/trunk/fcgi.py
chmod 755 fcgi.py
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.
#!/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()
chmod 755 dispatch.fcgi
Apache’s mod_rewrite module will pass all requests to your website through dispatch.fcgi, and thus, into Django’s URL dispatcher.
.htaccess (nte the leading dot) in your subdomain directory (for me, django.jeffcroft.com). Add the following lines to the file:
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
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.
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.
ln -s $HOME/django/django_src/django/contrib/admin/media $HOME/django.jeffcroft.com/admin_media
ADMIN_MEDIA_PREFIX = '/admin_media/'
Add the admin application to your installed applications in django/django_projects/myproject/settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
)
python manage.py syncdb
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
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.
Sorry, the time to post comments to this entry has expired.
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!)
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:
You might try logging out and back in again (another way to active the changes).
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)?
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. :)
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
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.pyis now only used to start a project andmanage.pydoes everything else, not much has changed in the server setup).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?
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.
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. :)
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.
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.
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.
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 .bash_profile 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 .bash_profile.
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 .bash_profile (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 bash_profile after sourcing it, it still has $HOME etc, should these of been replaced with my actual home directory? Thanks again.
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)?
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 …
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.
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
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.
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. :-)
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! :)
022 // Yas // 05.15.2006 // 10:39 AM
Has anyone tried to set up Django on Media Temple?
023 // Peter Bowyer // 05.15.2006 // 1:06 PM
If you want to see PostgreSQL at Dreamhost then do vote for it
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.
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…
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…
027 // Simon7 // 05.18.2006 // 12:04 AM
Work like a charm, thank you!
—Simon
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.
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. :)
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.
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!
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:
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:
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.
034 // Jeff Croft // 05.21.2006 // 4:55 PM
Kevin, try this: http://www.djangoproject.com/documentation/models/many_to_many/
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.
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
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?
037 // Jeff Croft // 05.26.2006 // 8:48 AM
Brian:
Change the first line of django.fcgi to:
#!/usr/bin/python2.4038 // 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
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 /admin_media/. I tried to access the file /admin_media/css/login.css directly but it simply times out eventually giving me an internal error.
Any ideas where I might have gone wrong?
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?
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/admin_media/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/admin_media/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]
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.
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.
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.
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”
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).
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.
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!
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. :)
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?
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.
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).
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?
054 // Tomas Jacobsen // 06.04.2006 // 11:03 AM
The logs in my django.mydomain.com ?
[mod_security: 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 ”/admin_media/css/login.css”]
Or is there another log?
055 // Jeff Croft // 06.04.2006 // 11:15 AM
Okay, that’s not actually a Django error at all. That’s a mod_security error when trying to access /admin_media/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.
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 “admin_media” 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/django_src/django/contrib/admin/media $HOME/django.mydomain.com/admin_media . All on the same line btw. Is there another way to make the shortcut?
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.
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!
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.
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.)
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?
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.
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;:)
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 syncdbSorry about that. I fixed it above. :)
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!
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!
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 django_projects 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 django_projects — 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).
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
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.
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.197No 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.
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?
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.
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
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..
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
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 :)
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.
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
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.
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?
081 // Jeff Croft // 07.30.2006 // 10:40 PM
Chris-
If
django-admin.pycannot be found, it is because the directory that contains it (~/django/django_src/django/binif 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:Also, make sure you’re dealing with the file
.bash_profilein your hoe directory -- note the dot that starts the file name. You saidbash_profileearlier (no dot), so just wanted to make sure. :)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?
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 .bash_profile thing. I’ve followed your steps to the T but all I get when I try to source the .bash_profile is “Bad : modifier in $ ($).”
I copy and pasted everything so I’m not sure what’s going on.
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.
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.
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 .bash_profile should look like. I now have project1.myurl.com and project2.myurl.com should the last two lines of my .bash_profile be:
export DJANGO_SETTINGS_MODULE=project1.settings export DJANGO_SETTINGS_MODULE=project2.settings
? Or is this incorrect? If so what should it look like? Thanks.
087 // Jeff Croft // 08.07.2006 // 2:23 AM
Sam-
I’m afraid you can’t have your DJANGO_SETTINGS_MODULE 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 DJANGO_SETTINGS_MODULE is set to project1.settings and you need to do something (say, syncdb) on project2, you could do something like this:
In short, django-admin.py will take it’s settings from your DJANGO_SETTINGS_MODULE and manage.py will take them from the directory you’re in.
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.
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/django_src/django/bin` export PYTHONPATH=$PYTHONPATH:$HOME/django/django_src:$HOME/django/django_projects
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
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:
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’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
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’]
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…
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.
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
092 // Jeff Croft // 08.22.2006 // 8:57 AM
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.
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.
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
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
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.
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.
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!
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 // 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 // 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 // Jeff Croft // 09.07.2006 // 9:18 PM
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 // 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 // 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 // Tom // 09.12.2006 // 8:27 AM
Any thoughts on this flup approach to FastCGI as suggested by the Dreamhost wiki?
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 // John McCaine // 09.18.2006 // 1:55 PM
Having difficulty with displaying the admin. The following message turns up:
/home/username/django/django_src/django/core/urlresolvers.py in geturlconf_module, line 173
Thank you
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:
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 // 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 // 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 // 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 // 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/flup_src/flup/server/fcgi_base.py”, line 558, in run protocolStatus, appStatus = self.server.handler(self) File “/home/kimmaydesign/resources/flup_src/flup/server/fcgi_base.py”, line 1112, in handler result = self.application(environ, start_response) File “/home/kimmaydesign/resources/django_src/django/core/handlers/wsgi.py”, line 185, in call response = self.get_response(request) File “/home/kimmaydesign/resources/django_src/django/core/handlers/base.py”, line 59, in get_response response = middleware_method(request) File “/home/kimmaydesign/resources/django_src/django/middleware/common.py”, line 41, in process_request if settings.APPEND_SLASH and (old_url[1][-1] != ‘/’) and (‘.’ not in old_url[1].split(‘/’)[-1]): IndexError: string index out of range
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 // Eric Smith // 11.01.2006 // 4:10 AM
I’ve just found this interesting post on Dreamhost Discussion Forum: http://tinyurl.com/ykbl2p
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 // 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 // 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 // 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 // Ulysses // 11.21.2006 // 7:54 PM
found fcgi.py here
http://svn.saddi.com/py-lib/trunk/fcgi.py
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 // 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 // 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 // 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 // Jeff Croft // 12.26.2006 // 8:55 PM
Whoops! Thanks, Joe! I’ll fix that now… :)
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 // 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 // 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 // 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:
settings.pyto 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 // 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 // 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 // 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 // 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 // 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 // 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 s135 // 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 // 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:
I also seem to be getting the dreaded error 500 message, even when running my hello.fcgi file.
Can anyone help me out?
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 // Jeff Croft // 03.23.2007 // 8:48 PM
James-
My apologies. The
installcommand has been removed from the manage.py script in the most recent versions of Django. Instead, you want to dopython manage.py syncdb. I've updated the tutorial to reflect this.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 // 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 // Jeff Croft // 03.25.2007 // 11:05 AM
@ehh: This is a temporary problem that only applies to (the just-released) Django .96,and will go away when Dreamhost upgrades MySQLdb. I may revise the article to mention it, but it’s definitely just a temporary issue.
@Marek: I host six different Django-powered sites on three different Dreamhost servers and have never had to ask for a memory increase. I’m not sure what is causing the problem you’re having, but it’s definitely not normal.
142 // Marek Ryćko // 03.25.2007 // 1:22 PM
Jeff, the problem I have mentioned, probably applies only to he sites run by Apache2. It is explained in the Dreamhost wiki:
So, for new customers (I have been at Dreamhost since November 2006), according to what they explain in the wiki, there is no other way as to ask for changing the Apache memory restriction.
143 // Jeff Croft // 03.25.2007 // 1:27 PM
Ahh, thanks for the clarification, Marek. Still seems odd, though. I’ve built Django sites on two entirely new domains and Dreamhost accounts in the past month without having this problem.
144 // Ben Spaulding // 03.28.2007 // 2:34 PM
Fantastic tutorial — I never could have got Django running on DreamHost without it.
Now I would like to run two sites in the same DreamHost account on different Django instances. I assume that I have got to do something with the .bash_profile, but I can’t figure it out — I just keep crashing both of the sites :-)
145 // Navin // 03.31.2007 // 1:57 PM
When I issue command
django-admin.py syncdb
I found Loading ‘initial_data’ fixtures… No fixtures found.
What shoud I do?
Thanks
146 // Jeff Croft // 03.31.2007 // 2:08 PM
@Ford: Yikes. Bad idea. Don’t go changing Django’s source! Instead, just use Python 2.4 — it’s installed on Dreamhost, as well.
@Ben: Another site, in Django tems, is another project. You just create another project under your
django_projectsdirectory, set up the hosting for it in the Dreamhost panel, add thedisptach.fcgi,fcgi.py, and.htaccessfiles to the new site's root directory, and you're good to go.@Navin: Sounds like everything synced fine. You shouldn’t have any initial data fixtures, so it’s accurate that it would say “No fixtures found.” Sounds like everything went right, to me.
147 // Venky // 04.21.2007 // 9:56 PM
Nice tutorial, worked as documented. Just remember for dreamhost to change the python path to /usr/bin/python24
148 // YoBabyPop // 04.22.2007 // 10:23 AM
Despite having successfully pressed dreamhost to prep my host and modifying my .fcgi file to the new ‘dispatch’ standard, my app is still failing to launch and dropping the ‘header’ error discussed above in my log. Postings here and at other sites suggest that the problem may be in some setting specific to my server at dreamhost. When I log into the FTP, the box is called nerds.dreamhost.com. So I assume that’s the proper title for my distant host server. Does anyone else share that host? And, if so, have then be able to get django working?
149 // tiddman // 04.25.2007 // 8:46 AM
Jeff, thanks for a great tutorial, this is exactly what I have been looking for. Thanks also to everyone else in the thread for the Q&A.
Unfortunately I haven’t been successful in getting this up and running. I am getting the “incomplete headers (0 bytes)” and http errors that others are getting, and have been beating my head against this for a while. Let me run something by you guys.
I first tried to get a “hello world” FCGI script running, and that failed. This led me to believe that there is a problem with my shell / process environment. I have this in my ~/.bashrc:
export PYTHONPATH=”$HOME/packages/lib/python2.3/site-packages”
But when I invoke my python script via my web browser, it looks like the .bashrc file is not read.
I created this trivial script:
!/usr/bin/env /usr/bin/python
import os print “Content-Type: text/plainn” print “PYTHONPATH=”,os.environ.get(“PYTHONPATH”)
and when I invoke this from the web, I get this:
PYTHONPATH= None
I’ve e-mailed Dreamhost support and they said that I should add parameters to env, like this:
!/usr/bin/env PYTHONPATH=/foo/bar /usr/bin/python
import os print “Content-Type: text/plainn” print “PYTHONPATH=”,os.environ.get(“PYTHONPATH”)
However, when I execute this script, it hangs indefinitely.
I suspect what is happening is that the script is being invoked, but it can’t find fcgi.py (which is in my PYTHONPATH), and it flops with the “0 bytes” errors. But running the script from the shell command line works fine, because the environment has the correct PYTHONPATH.
I wonder if I am barking up the wrong tree here? Any comments most welcome.
150 // Nathan Black // 05.26.2007 // 2:28 AM
It should also be noted that with Django 0.96 MySQLdb 1.2.1p2 is required. Since I don’t know how to get that setup around Dreamhost, I was able to get Django running by setting DATABASE_ENGINE = ‘mysql_old’ ( in section settings.py 2 Python ). Any suggestions about how to get this working correctly would be appreciated…
Thanks for the great article!
Nathan
151 // Jeff Croft // 05.26.2007 // 11:27 AM
Nathan, perhaps you just missed it, but there is a note about the requirement for
mysql_oldright under the settings.py 2 code snippet in the article.152 // Paul Hildebrandt // 06.09.2007 // 5:45 PM
Jeff,
I appreciate the time you took to layout this step by step installation. I’ve been using Python for about 3 years but I don’t know anything about Django. Your page got me up and running. I am going though the Django tutorial now and hope to have a site up soon.
Thanks,
Paul
153 // Matt // 06.16.2007 // 12:37 AM
Jeff,
First, thanks so much for writing this tutorial. I’ve gotten most of the way through it without a hitch and I could never have figured this out alone.
I come across an issue when I tried to view my site after enabling URL Rewriting. I’m not getting the 500 error others are experiencing, though. I’m getting a 404 claiming it can’t find dispatch.fcgi even though I am looking at the directory showing that it exists (and has been properly chmod’ed, etc).
I’m pretty new to Python, FastCGI, and pretty much all web development so I don’t want to tinker too much in fear of breaking something. If you can even point me in a direction that I could start looking for a solution I would greatly appreciate it.
Thanks again.
154 // Matt // 06.16.2007 // 12:51 AM
Well, obviously as soon as I asked my question, I found the answer myself minutes later.
Thanks again.
155 // Garrett // 06.19.2007 // 9:33 AM
Excellent writeup and I encountered no problems when I installed on my dreamhost account today (6-19-07). Looks like dreamhost is still using the older version of the MySQLdb Python module.
156 // Paul // 07.10.2007 // 2:47 PM
Jeff-
I just learned that my site statistics are broken after using your howto. IT’S YOUR FAULT! :) Kidding. Anyway, I made a post on how to fix it if you’d like to edit your howto. It’s simple line for
RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
Here’s the link http://theironlion.net/blog/dreamhost-django-and-site-statistics/
Paul
157 // Yuki // 07.24.2007 // 2:01 AM
Jeff, thanks for the writeup. However, I could not get it to work. I think it’s more of a problem about Dreamhost and fastCGI than anything else, because I was able to get hello.fcgi working one day, but couldnt get it working today. Dreamhost is quite limited in its support of fcgi and therefore python based framework.
158 // Silveira Neto // 08.02.2007 // 5:26 PM
This time I did everything step by step, but I did’t get it. I get nothing in django.silveiraneto.net or django.silveiraneto.net/admin, even a 404. Just the browse keeps loading… :(
159 // Federico Fasce // 08.22.2007 // 11:15 AM
Hi everyone! I write here, just to check out if someone can help me. I made my django installation on Dreamhost both following Jeff tutorial and the variant provided in the Dreamhost Wiki page.
Nothing works. I keep to get these nasty 500 errors, with the 0 bytes header error in the log file.
I tried even to make DH raise my memory limit, as suggested in the comment, with no luck at all.
Did someone solved that? If so, how? I’m trying hard for a week now, but with no results…
160 // JPD // 08.24.2007 // 5:58 AM
Just to confirm: At Aug 24, 2007, contacting Dreamhost support to get a bump to your apache memory limit is still necessary to get FastCGI working properly. Thanks to all who mentioned it above and saved me loads of time (and to Dreamhost for the lightning quick support response time, as usual ;)
161 // Jeff Croft // 08.24.2007 // 10:36 AM
@JPD: Thanks for the tip. I still have never had to ask for a memory limit increase on any of my Dreamhost installs of Django (which is about five different sites). So, it’s definitely not required for everyone. But, good to know.
162 // Dan Walter // 08.28.2007 // 10:41 AM
I get the same problem as ‘JPD’ posted (browser just hangs). Stepped through everything. Granted, I am not a Python expert…any ideas what I could have missed or what I should try?
Thank you for this great tutorial…well done.
163 // Dan Walter // 08.28.2007 // 11:10 AM
oops…I was referring to the post that ‘Silviera Neto’ made.
btw…I get the 500 error on /admin
thanks again.
164 // Kit // 08.31.2007 // 12:41 AM
Hey Jeff, Ran through your walk through a few months back to install django on a sub domain so that i could play around with django to see if i could switch from movable type. i was able to get it running on a sub domain with no issue, but now that I’ve gone back to set everything up to run on the primary domain I’m getting a 500 server error. based on the comments i only put the three files (fcgi.py dispatch.fcgi and .htaccess) in the domain folder and changed django.fcgi to dispatch.fcgi based on comments as well. not really sure if there’s something else i can check but if you have any thoughts I’d appreciate it.
thanks, kit
165 // Kit Churchill // 09.07.2007 // 2:41 AM
Jeff et al, I was looking for information here on getting docutils running and saw that some people had asked but there wasn’t an answer on how to make it work. I was able to get docutils running tonight and thought I’d pass along the information based on the rest of this tutorial.
using shell: cd into django/django_src/django/contrib run wget http://docutils.sourceforge.net/docutils-snapshot.tgz type tar xzvf docutils-snapshot.tgz cd into docutils type python setup.py build type python install.py —prefix $HOME
then in your dispatch.fcgi file add the line:
sys.path += [‘/home/username/lib/python2.3/site-packages’]
right after the two other sys.path lines. then pkill python, refresh your admin page, and you’ll have access to the admin documentation page. hope that helps.
Kit
166 // Amaltas // 09.26.2007 // 5:29 AM
I have an account at webfaction.com and they provide very good support for django. I recently bought an account at dreamhost, and following your instructions. Nice article
167 // Amaltas // 09.26.2007 // 6:33 AM
Well, current version of django requires MySQLdb-1.2.1p2 or newer.
Dreamhost has 1.2.1g3
So current django source is not working, django-admin.py syncdb fails with errors.
168 // Amaltas // 09.26.2007 // 6:36 AM
Ok, my fault, I failed to read http://www.djangoproject.com/documentation/release_notes_0.96/#backwards-incompatible-changes
And my django installation is up and running, Nice article. Thanks
169 // Sergi // 09.29.2007 // 3:33 PM
Hi! I tried it but don’t run yet.
In my case I created django.sergilario.com domain.
//// django-admin.py runserver
Validating models… 0 errors found
Django version 0.97-pre-SVN-6436, using settings ‘myproject.settings’ Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
//// http://www.django.sergilario.com/
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@django.sergilario.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
//// error.log:
[Sat Sep 29 13:13:27 2007] [error] [client 89.130.27.229] FastCGI: comm with (dynamic) server “/home/.trini/sergilario/django.sergilario.com/dispatch.fcgi” aborted: (first read) idle timeout (60 sec) [Sat Sep 29 13:13:27 2007] [error] [client 89.130.27.229] FastCGI: incomplete headers (0 bytes) received from server “/home/.trini/sergilario/django.sergilario.com/dispatch.fcgi” [Sat Sep 29 13:14:37 2007] [error] [client 89.130.27.229] FastCGI: comm with (dynamic) server “/home/.trini/sergilario/django.sergilario.com/dispatch.fcgi” aborted: (first read) idle timeout (60 sec) [Sat Sep 29 13:14:37 2007] [error] [client 89.130.27.229] FastCGI: incomplete headers (0 bytes) received from server ”/home/.trini/sergilario/django.sergilario.com/dispatch.fcgi”
//// dispatch.fcgi
!/usr/bin/env python
import sys sys.path += [‘/home/sergilario/django/django_src’] sys.path += [‘/home/sergilario/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()
//// Can you helpme please?
170 // Al Hounsell // 09.30.2007 // 10:19 PM
for people getting 500 errors try the following tutorial http://www.gordontillman.info/Development/DjangoDreamhost
171 // soulgt // 10.03.2007 // 2:19 AM
Thank you very much (a year+ later) for a great article.
I’m hosted on A Small Orange and was tearing my hair out with various tutorials trying to get Django working. Yours worked immediately. I can now keep some of my hair.
I have a quick question, which may be trivial, but after I installed the admin-interface, navigating to the subdomain itself - django (dot) soulguidedtelescope (dot) com yielded the following error instead of the ‘it’s working’ page:
Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order: 1. ^admin/ The current URL, , didn’t match any of these.
I’m just getting started and trying to learn, so is this something I should be concerned with? Is there a simple fix?
Thanks again.
172 // Jeff Thorsett // 11.06.2007 // 2:44 PM
Much like the first poster, I have the following problem:
The following is my current python path (mcclure is running 2.3.5):
I am using Django revision 6654 checkedout on Nov 6th, 2007
173 // orimarti // 11.14.2007 // 4:47 AM
Do you know if I can configure the django site for the main domain, not for a subdomain? For jeffcroft.com, not for django.jeffcroft.com
174 // jung // 11.23.2007 // 11:07 AM
Is there any way to have dreamhost’s default file of ‘bash_profile’? Because I didn’t know that files should be in home directory, i just replace with only two lines.
or
Could anyone of you send me default file at the2ndday@gmail.com
175 // schmiddy // 02.10.2008 // 7:23 PM
Hey.. for those getting the really slow loads and eventual 500s (I was getting error.log entries like ” FastCGI: incomplete headers (0 bytes) received from server “/home/myusername/myhostname/dispatch.fcgi” )with trying to get the basics working.. you should first check that you have flup!
I noticed that hello.fcgi tries to import the “flup” module with the line “from flup.server.fcgi import WSGIServer”. To test if you have flup installed, run “python” to get into the python interactive interpreter, and enter “import flup”. If nothing happens, you have it. If you get an error, you need to install flup. I used some information here: http://www.gordontillman.info/Development/DjangoDreamhost
about installing flup.
Hope this helps someone. Jeff, thanks so much for putting this information together.. I wouldn’t have been able to get things working without it.
176 // Michael DiBernardo // 02.15.2008 // 12:22 PM
Excellent tutorial, and schmiddy: thanks for the wicked helpful tip! That had been bothering me for a little while now!
177 // Kosta Kliakhandler // 03.01.2008 // 1:48 PM
Thanks for this tutorial!
Thanks also to schmiddy - I’m glad I looked at the comments of the tutorial straight away before going off and trying to troubleshoot it myself…
Jeff - you might want to add that info to the tutorial.
178 // Beshr // 04.07.2008 // 5:36 AM
Thanks jeff for this amazing tutorial…
But I’m still having some problems! I read nearly all the comments and nothing helped!
What I’m getting is 500 Internal Server Error, I have flup installed.. everything is exactly the same as you said.. but still nothing is happining? what’s wrong?
179 // Behr // 04.07.2008 // 9:41 AM
Worked :)
I just needed to raise Apache memory :)
Thanks =)
180 // Vincent Bumgarner // 04.15.2008 // 7:25 PM
I missed this step after enabling the admin application.
django-admin.py syncdb
The first step is off to the right of the brown box in Firefox.
181 // Mike // 04.29.2008 // 5:53 PM
Thanks for the tutorial.
I hope you’ll consider changing the styling: brown text on a black background just disappears on my monitor (on Firefox; when viewed on IE7, the upper-left link only appears when the mouse is hovering.)
Thanks.
182 // Stan Lan // 05.22.2008 // 2:13 PM
Great article.
It was mentioned before, but to fix the 500 error above, checkout the Dreamhost Django wiki:
http://wiki.dreamhost.com/index.php/Django
500 errors and Incomplete Header in logs
Dreamhost apparently runs a background process to kill zombie processes. This can cause issues for FastCGI dispatchers (like the one needed to get Django working). Because of this, Dreamhost updated their zombie-killer to avoid dispatch.fcgi; in other words, if you don’t rename the file mysite.fcgi to dispatch.fcgi your site will not work. The file name is different than the one mentioned on various other tutorials. You must also use
!/usr/bin/python2.4
183 // Norm Aleks // 06.17.2008 // 5:09 PM
Thanks for this tutorial! Very helpful. I too was having problems with “FastCGI: incomplete headers” errors, and the solution for me was to separately add flup, as schmiddy mentioned. Maybe you should add that to the tutorial? The error message is totally unhelpful, as is most of the material on the Web, and that little problem gave me at least an hour of irritation …
Thanks again.
184 // Jason // 07.10.2008 // 4:42 PM
Thanks for the DreamHost Django tutorial.
I’ve tried all of the fixes for the 500 error and can not get this to work. This is actually my second time through your tutorial and I can’t make this happen. I contacted Dreamhost support regarding the memory restriction for Apache2 and got a response that Django was unable to even start due to a syntax error in my dispatch.fcgi. I retyped the whole file and I still get the 500 error, what else can I do?
Thanks,
Jason
185 // Mikel // 07.23.2008 // 9:23 PM
Thank you for this great tutorial!
I’ve tries step by step, but when I run django-admin.py syncdb I get this error:
– cut here – Traceback (most recent call last): File “/home/mikelsegovia/django/django_src/django/bin/django-admin.py”, line 5, in ? management.execute_from_command_line() File “/home/mikelsegovia/django/django_src/django/core/management/init.py”, line 292, in execute_from_command_line utility.execute() File “/home/mikelsegovia/django/django_src/django/core/management/init.py”, line 248, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File “/home/mikelsegovia/django/django_src/django/core/management/base.py”, line 77, in run_from_argv self.execute(*args, options.dict) File “/home/mikelsegovia/django/django_src/django/core/management/base.py”, line 90, in execute self.validate() File “/home/mikelsegovia/django/django_src/django/core/management/base.py”, line 117, in validate num_errors = get_validation_errors(s, app) File “/home/mikelsegovia/django/django_src/django/core/management/validation.py”, line 22, in get_validation_errors from django.db import models, connection File “/home/mikelsegovia/django/django_src/django/db/init.py”, line 24, in ? backend = import(‘%s.base’ % settings.DATABASE_ENGINE, {}, {}, [”]) ImportError: No module named mysql_old.base – cut here –
Any clue?
Thanks, Mikel
186 // Joel Watson // 10.03.2008 // 10:35 PM
Hey Jeff,
As with a few others, I’m having a dispatch.fcgi error. I’ve tried Flup and the Quirks section of the Dreamhost wiki. In every instance, the ‘Hello World’ script works. When I try your version, I receive the 500 Internal Server Error. My error log reads:
[Fri Oct 03 19:56:21 2008] [error] [client] FastCGI: comm with (dynamic) server “/home/…/…/dispatch.fcgi” aborted: (first read) idle timeout (60 sec) [Fri Oct 03 19:56:21 2008] [error] [client] FastCGI: incomplete headers (0 bytes) received from server ”/home/…/…/dispatch.fcgi”
Any ideas…
187 // Alex // 10.07.2008 // 3:25 PM
Dude it would be great if you provide a pdf with the instructions… i’ve been trying to copy&paste from here and all i get working well is the front-end.. but the admin is still messed up…
188 // TonyB // 11.17.2008 // 6:12 AM
Hey, thanks for this great guide.
Just a quick question… is anyone having any trouble with syncdb? It worked originally. but I’ve just updated my models.py, then run ‘python manage.py syncdb’. The command executed without errror, but the mysql databse has not been updated. Any ideas?
Cheers, Tony.
189 // Border // 11.26.2008 // 10:16 PM
Great guide.
Thanks Bian Jiang.
190 // Brian Corrigan // 02.09.2009 // 5:15 PM
Tony,
Try resetting your sql. I think the command is
python manage.py reset
(if not, run python manage.py and it will give you a list of options. Look for the one to reset the app db)
When you change existing models, django wont pick up the changes, only new or deleted models.
This should work.
Brian
191 // corrine // 05.11.2009 // 9:24 AM
Very helpful!! Thank you!
192 // Bryan // 05.18.2009 // 2:44 PM
Thanks a bunch, Jeff. This was very helpful.
193 // vincent // 05.21.2009 // 9:10 AM
HI,I have a trouble.I setup python 2.5 + mysqldb 1.2.2,and I can use exec cmd: $ python >> import MySQLdb >> MySQLdb.version_info (1,2,2,’final’,0) but when i access my site with url or exec ‘./dispacth.fcgi’, then an exception which meaning is ‘no mudel named MySQLdb’ was throwed, I don’t know why? help me! thank you very much!
194 // matthew // 06.02.2009 // 9:58 PM
The mysterious 500 errors may be the result of extra whitespace in the dispatch.fcgi file.
195 // Pietro Speroni // 06.22.2009 // 8:33 AM
Thanks. I had an Internal Server Error, eventually I discovered that on dispatch.fcgi the different indentation between the first line and the next were giving problems. Also I changed the first line as suggested on the dreamhost wiki. So I used:
Which finally worked. It would be good to update the code.
Many many thanks, Pietro
196 // Drew // 08.25.2009 // 4:31 PM
This guide is awesome. Very easy to follow.
Wanted to know if anyone knows what the problem is when I try to syncdb
dayberrya@eagles:~/django/django_projects/myproject$ django-admin.py syncdb Error: Could not import settings ‘myproject.settings’ (Is it on sys.path? Does it have syntax errors?): No module named myproject.settings
The syntax looks ok in the file. Anybody seen this before? Any help would be greatly appreciated.
-Drew
197 // Byron // 08.27.2009 // 2:49 PM
I’m having the same problem as Drew above? Anyone have a clue? Man this Django sounds cool, but I find that it seems that no tutorial works for me on my new Mac. HELP PLEASE! Thanks…
198 // Ramanathan // 09.14.2009 // 9:08 AM
changes i make in urls.py file are not getting reflected when i give the url in browser.
for example i have changed my entry from (r’^(.+)/$’,’project.app.views.activate’) to (r’^activate/(.+)/$’,’project.app.views.activate’)
but still entries are getting matched with the older one which does not even exists in urls.py file.
what has to be done?
Regards, Ramanathan M
199 // Tom // 10.05.2009 // 8 PM
Thanks so much for your tutorial. It definitely made this process so much easier!
200 // Juan // 10.14.2009 // 6:04 PM
Hey Jeff!
First off, fantastic tutorial.
I’ve got a problem. I’ve followed everything correctly (i think!), and im all set up to accessing the admin url. I get a HTTP 500 Error. When looking at the error.log, i get:
[Wed Oct 14 17:52:13 2009] [error] [client 171.66.49.179] Premature end of script headers: dispatch.fcgi [Wed Oct 14 17:52:37 2009] [error] [client 171.66.49.179] Premature end of script headers: dispatch.fcgi [Wed Oct 14 17:52:41 2009] [error] [client 171.66.49.179] Premature end of script headers: dispatch.fcgi [Wed Oct 14 17:52:53 2009] [error] [client 171.66.49.179] Premature end of script headers: dispatch.fcgi
any ideas why? i edited using VIM so probably no line endings/file formatting issue… i tried reading other comments, but no suggestions seem to work.
Any thoughts?
Thanks in advance!
~Juan
201 // Juan // 10.14.2009 // 7:11 PM
UPDATE: Fixed!
when editing django/django_projects/myproject/urls.py
make sure to also uncomment:
Cheers!
Juan
202 // External drive // 12.14.2009 // 1 PM
To be honest, I was once considering using Dreamhost but I read bad reviews about this service so I ceased to use this host.
203 // Jacob Morris // 01.31.2010 // 3:22 PM
Thanks for these fantastic instructions!
I saw plenty of versions online, but yours is obviously the original and best.