Day: July 18, 2005

  • Pimp My Django

    Pimp My Django

    Yeah, baby! Thanks to tons of SVN updates, I’ve managed to plow through the second Django tutorial unscathed. I’m really impressed with the admin interface and how a dab of Python can do stuff like create a sidebar or create a rocking search interface.

    Huzzah!

  • Hey Apple: That\’s Just Silly!

    AppleInsider:

    Under the revised store hours, most Apple retail locations will operate: 7 a.m. to 10 p.m. Mon-Fri, 8 a.m. to 10 p.m. on Saturdays, and 10 a.m. to 9:30 p.m. on Sundays, according to ifoAppleStore.

    Aww, comeon. Who did you pay how much to come up with that? You’re going to loose money on this and go back to the old hours eventually. Trust me.

  • Django: Making it Easier

    Yes! Adrian has just commited a patch that bypasses mod_python completely!

    mcroydon@mobilematt:~/django/proj$ django-admin.py runserver
    Starting server on port 8000. Go to http://127.0.0.1:8000/ for Django.

    svn up in your django_src dir and enjoy.

  • Django Gotchas

    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:

    1. 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 test module. 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
    2. Your project directory should be somewhere in your Python Path. Under Linux your best bet is to set the PYTHONPATH environment variable. Here’s the gotcha, if your project is in /path/to/project, you actually want to set your PYTHONPATH variable to /path/to. On a per-session basis you can do this by doing something like export PYTHONPATH=/path/to
    3. In order to really use django-admin.py as often as you’re going to, you really want to symlink it to /bin or /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.py did the trick.
    4. Really pay attention to the install instructions and make sure you symlink your django install to /usr/lib/python/site-packages correctly.
    5. 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>

      The PythonPath to the directory containing your project is again quite critical. This is where the test collision 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 On is 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?

    Thanks again to everyone in #django on Freenode for all the help and guidance. Now it’s time to get back to that login gotcha.

    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.