Fork me on GitHub

Four Exciting Django Developments

On day 2 of the Vancouver Django Jam I got a chance to meet the Django web framework's lead developer Adrian Holovaty and get the scoop on the latest developments in Django (including the generation of end-user interfaces to data!).

Revamped Form Engine

Django's biggest improvement (currently available only via Subversion) is the revamping of the form engine. While the previous form engine required tedious additions to templates (to deal with validation errors and the like), the new incarnation does it all for you, creating all form HTML and allowing form definitions to be generated from models. This is a big deal as it will greatly improve the speed of Django development.

In addition, the new form implementation has been incorporated in the Django web administration module. This makes the admin interface easier to customize and allows the configuration of custom per-object permissions.

New Form Widgets Allow Contributed AJAX/Javascript Integration

One thing Django developers get asked about frequently is the possibility of adding automatic Javascript generation to the framework. Ruby on Rails includes this functionality but Adrian likens this to using an electric wheelchair when you're capable of walking. Needless to say, there are no plans to add automatic Javascript generation to the framework.

The new forms engine, however, includes a "widget" interface which could allow the creation of add-on Javascript generation. The widget interface allows handlers to be specified for individual form fields. Adrian confirmed that widgets could be used to auto-generate Javascript and interface with AJAX response handlers.

"Electric wheelchair" or not, the contribution of AJAX-enabling widgets would definitely help sell the framework.

Databrowse: Generation of End-User Interfaces to Data

Another interesting Django development is Adrian's experimentation with auto-generation of data browsing interfaces.

Holovaty's concept of "programmer journalism" involves creating interfaces that allow end-users to explore data and unearth trends (one example is the Washington Post's Congress Votes Database). He refers to the creation of these interfaces as "giving [data] the treatment". Developing these interfaces, however, can be tedious. Given that these interfaces are often similarly structured, automating their creation is primarily a matter of analyzing and abstracting the structure then adding hooks to Django.

Adrian's notebook contains his first attempt to do this. He demonstrated his "databrowse" module in action and it seemed like a very useful tools, even just for allowing clients to surf their own data and get ideas for site development.

Once Adrian's code stabilizes it will likely be included in the Django distribution or available for download.

Automatic Escaping of Data in Templates

While not completed yet, automatic escaping of data in templates is another Django feature that is planned for development. Using the current release, each data field passed to a template needs to be explicitly escaped. This creates work for developers and imposes a security risk if data isn't escaped.