Wednesday 10 September 2008

Moving to Django

Well wow.gedsguides.com needs a bit of t.l.c. — a facelift and some new functionality. And rather than plod through acres of Java code (and, IMHO, now that everything is supposed to be done via annotations it's actually more error-prone rather than less) I'm looking at Django to do the business.

Mostly I like what I see. The Django developers seem to be a pretty smart bunch, and if they've had to balance power, flexibility, economy and expressivity they seem to have got a very good bargain.

So there's just a few things I don't like. Number one (and I won't bother about the rest) is syncdb. I want to design my database first, and then have the ORM layer work with that. I don't want to design the object layer first and then have the database constructed from it automatically. I suppose I'm showing my age, swimming against the tide of history, etc. etc. And to a degree, it's a bit cheeky of me to expect to be able to use an ORM approach like Django's without having to pay the price.

Still, so far I've only installed Django and worked through the tutorial. I've yet to read the reference documentation for the models module(s). It may be that you can finesse the default behaviour, I hope so — and the flexibility and customisability I've seen in the rest of Django certainly gives me cause to hope; it would be a shame if it was completely hard wired in this one area.

I'll look at Djangoising the admin interface first. Since it's a completely separate application, I can do it in Django while leaving the public site still running with servlets/jsps. And I get the benefit that all I have to do is define the models and Django will generate an automatic admin interface for me — that's very attractive! (Subject to the proviso above, of course.)

And when and if the time comes to deploy it, I can even do it in baby steps, by simulating python/Django on the java server with the magic of jython: Deploying Django/Jython Projects on a J2EE App Server.

2 comments:

  1. Check:
    http://docs.djangoproject.com/en/dev/howto/legacy-databases/

    ReplyDelete
  2. Nice, very nice, thank you for pointing that out. So far I'd done two tables by hand, just as an exercise, and I noticed your comment just as I was about to do the remaining ones; so that came at exactly the right time, thank you :))) .

    ReplyDelete