Field Notes Inside an Integrated Communications Agency

newforms-admin

  • Using Django QuerySet Refactor, Newforms-Admin, Trunk and Pre-Autoescape on the Same Laptop

    Note: This little how-to works great for me and the way I work. I use a Mac laptop to develop Django sites which have a life as a production site somewhere else. If you work another way (like in Windows, or with Apache for development instead of Django's dev server, or if you work straight off the production server), this might not help directly, but I hope it helps get you started on finding a way to solve this little annoyance on your own. 

     

    So I do a lot of Django development on my laptop. I have a bunch of Django sites which I built over the course of the past two years or so - most of which I have to go back and work on a little every now and then. Because they've been developed at different times, most go back to before the new QuerySet refactor merge, and a few go back to before the Autoescape revision. I'm also looking at building my next site with the newforms-admin branch.

     I'm using subversion to check out the latest versions of Django. I usually check it out into /usr/local and then make a symbolic link to it in Python's site-packages folder. Because some of my sites raise errors when I run them with versions of Django released after they were written, I find myself changing the revision number of my laptop's Django occasionally (and by occasionally, I mean way too often).

    To get around that, I figured out that I can do this little trick. Now, in my /usr/local I have all the different versions of Django I'm likely to need. Like so:

    django/
    django-newforms-admin/
    django-pre-qsr/
    django-pre-autoescape/

    django-myclient/

    The one called just django/ is the latest trunk revision... the one I usually use. The others are the revisions (or close approximations of the revisions) that I used when I made some of the older Django sites on my laptop. Each of these folders contains a folder called "django".

    In the manage.py files for each of my sites where I can't or don't want to use the latest trunk revision, I just drop in a couple of lines right at the top:

    import sys
    sys.path.insert(0, "/usr/local/django-myclient/")

    This drops the path to my preferred Django rev onto the start of the sys.path list, and Python uses the first django module it finds in it's path. Now whenever I use manage.py's shell, dbshell or runserver commands, I'm using the Django rev number I need without having to fool around with svn update each time I need to work on a different site.