Archive for the 'Web development' Category

Fingers crossed…

Thursday, July 10th, 2008

I’ve just moved my various small Django projects across to newforms-admin. So far, so good…

Review: Practical Django Projects

Wednesday, July 9th, 2008

James Bennett’s Practical Django Projects is, by my count, the fifth book on Django to make it into print, but it is distinctly different from its predecessors.

The best of those predecessors, Adrian Holovaty’s and Jacob Kaplan Moss’ The Definitive Guide to Django (also published by Apress) continues to serve both as a reference and as an excellent introduction to the framework, detailing the philosophy behind Django and explaining how it differs from its rivals. However, The Definitive Guide is very much a ‘bottom-up’ book, exploring each of Django’s components individually by means of small examples. James has, interestingly, adopted the complete opposite approach in Practical Django Projects. The result is a book that complements The Definitive Guide superbly. This is essential reading for anyone wishing to step up from merely experimenting with Django to actually doing serious work with it.

Early Material

James’ approach is to guide the reader through the construction process for three realistic web applications: a simple CMS, a fully-featured blog and a site for uploading and rating code snippets. The first of these examples is the smallest, spanning Chapters 2 and 3 of the book. This example serves partly as a very basic introduction to key features of the framework - project configuration, the admin app, views, templates and models - and partly as a powerful demonstration of how a genuinely useful application can be constructed mainly from components already present in Django (in this case, the admin and flatpages apps), with barely any additional code.

James doesn’t leave it at that; in what is to be a recurring theme of the book, he makes his CMS more useful and interesting by also incorporating a third-party component - in this case, the TinyMCE JavaScript rich text editor, which is used in a customised admin template to enhance flatpage editing.

The Blog Example

The book is dominated by the second example app, a blog, which is developed over the course of the next four chapters. The basic data models, templates, view code and URL configuration needed to deal with blog entries are discussed in detail in the first of these chapters. This chapter also demonstrates the value of generic views and explains how to decouple an app’s URL configuration from that of the project that hosts it.

Subsequent chapters introduce the concepts of data model managers, template inheritance, custom template tags and Django’s signals mechanism. James very sensibly avoids covering every last detail of these advanced features; after all, you can go to The Definitive Guide or the excellent built-in/online documentation for that. The important thing is that these features are introduced in the context of a real application, making it much easier to appreciate the benefits that they bring.

Once again, James takes the opportunity to demonstrate how third-party components can be used to enhance an application - in this case, providing the ability to write entries using Markdown syntax, submit blog links to del.icio.us and filter comment spam using Akismet. The final version of the blog even has the ability to generate Atom feeds for links and entries that have been posted to it. It really is a fully-featured application, lacking only the CSS and JavaScript required for a professional look and feel. (A suitable stylesheet is supposed to be available from the Apress website, along with all of the source code described in the book, but this material wasn’t available at the time of writing this review.)

The Last Four Chapters

The final example app reinforces the techniques discussed in earlier chapters. Further advanced features of Django are also introduced - notably the customisation of ORM queries with extra SQL and the development of more complex template tags that have to parse ahead in a template - but the app serves mainly as a vehicle for introducing Django’s form processing capabilities. James gives a very thorough explanation of form validation here, which may clarify things considerably for less experienced Djangonauts.

The last chapter of the book is in some ways the most valuable of all. In it, James takes a step back from the code to provide general advice on how you can make it easier to reuse apps in other projects. Readers of his blog will have come across some of his advice before, but it is useful to see all of this material collated, expanded and on the printed page.

Conclusions

Practical Django Projects is a valuable addition to the growing library of books on the world’s best web application development framework. It isn’t a work of reference, but it is an excellent and detailed guide to the construction of flexible and reusable apps that make effective use of Django’s extensive capabilities. It could certainly serve as a good, top-down introduction to Django for someone with a background in other web frameworks and some prior experience of Python, although it isn’t a replacement for the more detailed exposition of Django design principles to be found in The Definitive Guide to Django.

No book is perfect, and this one has a few minor problems. There is the odd typo to be found in the text and the code examples which could trip you up if you are working through the example apps, and the use of third-party components needs to be explained a little more carefully, particularly with regard to which versions are required. (For example, I found out the hard way that the existing version of the markdown library on my Ubuntu machine wasn’t compatible with the blog app.) However, these minor flaws detract little from what is the new ‘must-have’ purchase for the beginner- to intermediate-level Django developer.

Practical Django Projects is here

Wednesday, July 2nd, 2008

James Bennett’s Practical Django Projects arrived in the post yesterday and it looks pretty good. I’ll post a proper review here later - I’m off sick today and don’t feel up to writing much :(

Django marches on…

Monday, April 28th, 2008

The inexorable rise of Django continues. Packt have now published Learning Website Development with Django, which by my reckoning is the fourth Django book to make it into print - with two more due this summer from James Bennett and Paul Bissex.

Then there’s the inclusion of Django in Google App Engine. Google’s endorsement will surely do a lot to raise Django’s profile. Although many Djangonauts have expressed disappointment that some of Django’s best bits are missing from or unusable in GAE, I think it still has value as a stepping stone to using the full framework.

One of Django’s great strengths is its very active community. In addition to heavily-used newsgroups and IRC channels, there is an excellent weekly round-up podcast, the nineteenth edition of which featured some particularly enlightening stuff on internationalisation. Then there’s a host of apps out there that both demonstrate the framework in action and support its growing band of users; djangopeople.net, djangosites.org, djangofriendly.com, djangosnippets.org, djangoplugables.com are the ones that spring immediately to mind, but I’m sure there are others that I’ve forgotten to mention.

At the heart of it all are some very dedicated, hard-working core developers. It was great to see Malcolm Tredinnick’s queryset-refactor branch merged in trunk, taking us one step closer to another major release of the framework. And Jacob Kaplan-Moss continues to work at refactoring the documentation (which I’m feeling slightly guilty about, since I’d offered to help but haven’t had the time to do so, as it turns out.)

All in all, life is pretty good in Djangoland.

Google App Engine

Tuesday, April 8th, 2008

This is very cool. And Python-based, to boot, with a strong Django flavour to it. Needless to say, I wasn’t quick enough to get a beta testing account. I’m on the waiting list, like countless others, no doubt…

This Week in Django

Wednesday, April 2nd, 2008

Michael Trier & Brian Rosner’s This Week in Django podcast is always worth a listen. I’ve found it to be a very useful way of keeping track of significant changes to trunk or newforms admin. It was good to hear mention of Changeset 7363 (based on my patch :)

SPA2008 - day 2

Tuesday, March 18th, 2008

A good day today.  Went to an intense but stimulating three-hour session on Python generators in the morning, which had gone beyond my prior knowledge of them within the first half-hour.  I was struggling to grasp some of the more advanced aspects of what was being demonstrated, but I certainly came out of the room with a better understanding than when I went in.

Other sessions of note included a panel discussion asking whether software practice had actually advanced over the past 15 years, and a thought-provoking presentation on the design of domain-specific languages.  Between this and the evening meal, I had the chance to run a Django BoF (basically just a demo and a discussion).  Four people turned up and we had some good discussion of Django vs. Rails.

SPA2008 - day 1

Monday, March 17th, 2008

I’m at SPA2008, the BCS conference for Software Practice Advancement - feeling quite tired after having led a 6-hour introductory tutorial on Python and Django.

I think it went reasonably well, although we were very pushed for time towards the end.  Cutting out one of the exercises helped, but the final group exercise on Django was still somewhat rushed.  I reckon we got far enough to convey the flavour of Django development, at least.

I might offer a BoF session on Django as a follow-up, to discuss some of the things that were omitted from the tutorial and to give other delegates an opportunity to learn about the best Python web development framework…

Django sprint

Sunday, December 2nd, 2007

Participated in another Django sprint yesterday. This time, I decided to ignore code and focus only on documentation. I managed a small patch to the docs on use of mod_python, plus a much larger patch that provides full documentation for the localflavor add-on. Not earth-shattering stuff, but hopefully someone will find this stuff useful once it gets committed.

Another Django book

Friday, November 16th, 2007

I don’t know, you wait ages for a book on Django, then suddenly two come along at once - the second one being Professional Python Frameworks: Web 2.0 Programming with Django and TurboGears, by Dana Moore, Raymond Budd and William Wright.

Actually, this particular tome has beaten Adrian and Jacob’s The Definitive Guide to Django to the bookshelves by a good month or more. I’ve only had the merest of chances to flick through it since it arrived from Amazon this morning, but it looks interesting. Once novel feature is an interview with TurboGears’ creator, Kevin Dangoor (but, regrettably, no equivalent interview with any of Django’s core developers). I’m looking forward to delving into this more deeply over the weekend, then comparing it with the official book in a month or so.

While we are on the subject of the official Django book, I notice that the cover has changed again:

Django book cover

Should help with brand recognition! I wonder how they persuaded Apress to let them use the Django logo in place of the regular styling used for the title text of every other Apress book?…