Multiple Django development versions on Windows


Having multiple Django versions on your development box is easy if you’re running a flavor of Unix.  You just use symlinks.  As Malcolm Trednick said on django-users:

I do it all the time. I five or six different Django codebases that I
use with some regularity and switching between them is pretty common
(and fast).

Actually, what I do for my normal development work is have a symlink in
the directory containing all my sources that I just flip to the version
I want to use at the moment. A symlink in python’s site-packages points
to /home/malcolm/BleedingEdge/Django/django_src/django and I just move
the django_src symlink to point to the version I’m using at the moment.
The reason for this extra link is because then I can do everything as
user “malcolm” without having to become root or use sudo.

Symlink tricks like this are natural on Unixes.  But what if your development box runs Windows?

For historical reasons, my development box runs Windows XP.  (I intend to change this soon.  Please don’t consider me a Luddite – it just hasn’t yet bubbled to the top of my list.)

The Windows UI has shortcuts, which are similar to Unix symlinks.  They’re similar enough that you’d think/hope you could use them like symlinks.  But they are different.  If you install multiple Django versions in a folder, and put a django shortcut in your site-packages folder, it won’t work.  From Windows explorer, it looks like it ought to work.  Python25\Lib\site-packages contains a django shortcut, which visually looks like a folder.  If you double-click it, it opens up the Django folder in that other folder.  But…when you try to crank up Django, Python won’t be able to find it.

The good news for Django development on Windows is that Microsoft put symlinks into NTFS under XP and Vista!   Microsoft calls them, “junctions.”  The bad news is, they’re not exposed in the Windows UI.  But by installing a command-line tool, you can use the symlink trick to run multiple Django versions on your Windows development box. Here’s what you do:

  1. I’m assuming that
    1. Your disk is NTFS-formatted
    2. Your Django versions are in c:\django_versions.  E.g., c:\django_versions\django096, c:\django_versions\djangotrunk, etc.
  2. Download Junction v1.05, written by Mark Russinovich.  Store the kit’s executable somewhere on your path.  I put it in c:\windows.
  3. Make sure there’s no preexisting c:\Python25\Lib\site-packages\django
  4. In a command window,
    1. cd c:\Python25\Lib\site-packages
    2. junction django c:\django_versions\djangotrunk

c:\Python25\Lib\site-packages\django now symlinks junctions to c:\django_versions\djangotrunk. Crank up Django and you’re at the races.

When you want to use a different Django version, just go to the command window and issue another junction command to point the django junction to a different django_versions folder.

If you know of an easier way to simulate symlinks on Windows, I’d love to hear about it.

4 thoughts on “Multiple Django development versions on Windows

  1. Brilliant. I added 2 .bat files in the django_versions folder:

    “trunk.bat” containing:
    junction C:\Python25\Lib\site-packages\django C:\django_versions\django_trunk

    and “0.97.bat” containing:
    junction C:\Python25\Lib\site-packages\django C:\django_versions\django0.97

    to make switching versions a one click affair.

    Thanks!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.