I know that a lot of these things will get ironed out or explained more clearly once the platform matures and more people start using it, but here are some tips for early Django adopters trying to get through the tutorials:
- Don’t name your project
test. I know it sounds like a good idea now. I did the same. Trust me though, at the beginning of Tutorial 2 you’ll start kicking yourself when you run in to namespace collisions with the
testmodule. In order to make this warning a bit more abstract, you’re best off not naming your project anything that is a Python module in the Python Standard Library
- Your project directory should be somewhere in your Python Path. Under Linux your best bet is to set the
PYTHONPATHenvironment variable. Here’s the gotcha, if your project is in
/path/to/project, you actually want to set your
/path/to. On a per-session basis you can do this by doing something like export
- In order to really use
django-admin.pyas often as you’re going to, you really want to symlink it to
/usr/bin. For me (again, under Ubuntu having checked out Django via Subversion),
ln -s /usr/lib/python2.4/site-packages/django/bin/django-admin.py /usr/bin/django-admin.pydid the trick.
- Really pay attention to the install instructions and make sure you symlink your django install to
- I’m still dealing with the newbie cookie authentication bug that tends to creep up partway through the second tutorial, but I was able to get the admin login to pop up by using the following settings for Apache2 and mod_python (with special thanks to #django and the Django on OSX installation guide):
<location /admin/> SetHandler mod_python PythonHandler django.core.handler PythonPath sys.path+['/home/mcroydon/django'] SetEnv DJANGO_SETTINGS_MODULE proj.settings.admin PythonDebug On </location>
PythonPathto the directory containing your project is again quite critical. This is where the
testcollision will show up if you’ve been foolish enough to name your project
test. Make sure that DJANGO_SETTINGS_MODULE points to your project. This worked perfectly for me under Ubuntu Hoary, but YMMV.
PythonDebug Onis your friend here and turns a plain jane 500 error into a traceback.
Gotchas like these are going to have to be minimized in order to not scare away newbies and also enable that “running start” feeling that you get with Rails. I’m sure that a few of these are mitigated by
setup.py in the tarball and the rest should be made a lot easier once WSGI support is added (and I’m glad to hear that adding a built-in server is on the list somewhere) should take care of the rest.
I do have to say that so far (gotchas aside) I’m really impressed with the platform. It’s great to be able to work with the Python interpreter to flush out some test data (you can do similar things with the Ruby interpreter with Rails, but Python is my native language). I also got warm fuzzies when someone asked if there was a mail module for Django. Heck, Python has an awesome standard library, why not use it?
Note: Django is a moving target right now. Since I wrote this early this morning, support for a standalone server has been added (just after WSGI support was added) and lots of little bugs and niggles are being taken care of as I type.