Posts tagged: DJANGO

Moving the blog to Django

The long-awaited (by me) conversion of this blog to Django is underway. After a couple hours’ work I have a full set of models and a functioning admin, and working index and detail views of postings and comments. Searching, posting comments, and tags are the major pieces remaining. Because of my busy schedule I’ll only be able to work on it in fits and starts, but I expect the total labor in the end to be about five hours.

The twenty-minute trouble ticket system

People are always going on about how it “only” takes twenty minutes or whatever to knock together some little application. Screencasts don’t count, unless they are screencasts of somebody who hasn’t done any preparation. But damn, I just built a trouble-ticket system in Django in twenty minutes. Really. Of course, I already had a running install, this is just something I added. But it was instantly useful. I assigned four tickets to myself and now I can go have dinner.

Django development tips

Working on a couple Django projects in tandem has me tuning my approach to using the built-in development server. I thought I’d share some of the techniques I’m using.

Here are the commands I’m going to talk about. If you understand it all from these lines, you’re done!

screen -S projectname
./manage.py runserver |& tee -a logs/devserver.log
^A ^D
tail -f logs/devserver.log
screen -r projectname
screen -list

Using screen

screen -S projectname

The GNU screen command is incredibly useful for all kinds of things, including longish-running processes that need to be checked and tweaked and stopped and started – like your Django development server. (Read more about screen if this is new to you.)

Django: less (magic) is more

Today I updated my Django play/development environment to the new magic-removal branch, and migrated my proto-wiki as an exercise. Following the RemovingTheMagic instructions on the official Django wiki made it fairly easy. (I added some notes on dealing with custom template tags.)

This branch is about more than cleaning up some of the needlessly clever bits found in earlier implementations; it also has some really nice syntax refinements. Compare this:

reporters.get_list(fname__exact='John', order_by=('lname',))

to this:

Soft launch

I quietly launched my first production Django site today, a replacement for a mess of legacy third-party PHP code. Unfortunately, it’s a members-only service related to my job and so I don’t have a public URL to share.

A couple interesting points: the new site was developed alongside the still-live legacy PHP apps, using some of the same data – including a user table that’s used for authentication. django-admin.py inspectdb made model creation fairly easy. I also found Scott Hurring’s PHPSerialize module indispensible for working with the highly crufty legacy data.