Weblog

July archive

Django weekly roundup: July 30

July 30, 2007

  • Siddharta Govindaraj has recorded an excellent screencast and posted it on ShowMeDo that illustrates how a relatively inexperienced Django programmer can create a basic Wiki application in 20 minutes.
  • Having trouble convincing your superiors that Django is a proven and reliable technology? Several Django developers at OSCON had that sort of issue. Coming out of those talks, Rob Hudson is now looking for individuals and companies who have had success with Django to contribute “Django success stories” to the Django wiki. Please add your own, and keep an eye on the page if you’re looking for that extra bit of ammunition to further your Django advocacy at work.
  • This week in GSoC news, Thejaswi Puthraya’s django-check-constraints project has gained ‘like’ and ‘between’ check conditions and more doctests. Thejaswi has also added a short tutorial on his site demonstrating how to use his project with newforms.
  • James Tauber has wanted a complete implementation of the Atom Publishing Format in Django for a long time: “You can’t produce full-content feeds without some hacking and the more advanced features of Atom are not supported. And Django certainly doesn’t have support for the Atom Publishing Protocol, which just got approved as an IETF Proposed Standard.” Just this past week, James has begun his project at Google Code, django-atompub to see his ambitions realized. The project’s first phase will be to complete the publishing format, but the future plans include fully implementing APP (Atom Publishing Protocol), which looks as if it will be bit more challenging—but certainly more rewarding as well.
  • Producing Django applications that can be cleanly distributed and included into other people’s projects has been a hot topic on the mailing lists this past week. The result of this discussion are many updates, clarifications, and new information on the Best Practices to Work with 3rd Party Apps wiki page: “Working with 3rd party / reusable applications used to be a pain for me as they are meant to live outside of your project folder structure, they either needed to live in your python site-packages folder or added to the python path; otherwise you would not be able to include them in your INSTALLED_APPS, use them in your project at all and you will end up seeing lots of “ImportError?: No module named …” type of errors.
  • Russell Keith-Magee has developed a patch for the Django testing framework which allows a user to run only individual tests of a particular test suite. If you’d like to test out this new functionality, check out a copy of the Django trunk greater than revision [5769].
  • Will Larson has developed a handy Django middleware that inserts your Google Analytics javascript code into your templates. Whether or not you find this middleware particularly useful, you may be interested in reading the article anyway. Will does an excellent job of describing the entire process of developing his project, and thus it also serves as a great tutorial on designing your own custom middleware projects.
  • Nathan Ostgard explains a use-case in which a Django application needs to be completely restricted to logged-in users and where only a few pages can be accessed by anonymous users. This runs contrary to the built-in decorators in Django which allow for specifying which sections of your site should allow authenticated users. Nathan has implemented a custom middleware that restricts all views to logged-in users without having to decorate them all manually. For those pages which need to be accessed by anonymous users, you can use Nathan’s @allow_anonymous decorator.
  • Jeremy Dunck, Jacob Kaplan-Moss, and Simon Willison gave a talk as OSCON titled Django Master Class which touched on some concepts that are usually left out of most Django presentations. The presentation covers topics such as unit testing, signals, custom fields, OpenID, and more. The slides are online at the link above along with the presenters notes which makes the read even more worthwhile.
  • Instant Django is a standalone, and portable installation of the Django environment for Windows users: “No installation is required. Simply download the self-extracting executable, double-click, and place the resulting ‘django’ folder in a convenient location. You can even carry it around with you on a USB thumb drive. The portable Django development environment also works with the official tutorial. Be aware that it uses the builtin Django development web server, so it can not and should not be used for deployment of Django projects.
  • Are you working with the Facebook API in your Django application? Would you like to? A tutorial has cropped up on the Facebook Developers Wiki that details how you can do just that.
  • In the final bit of “middleware” news for this roundup, I came across a very interesting bit on DjangoSnippets this past week. This middleware, by exogen, detects when your visitors have arrived from a search engine: “This isn’t actually middleware in the sense that it defines any of the middleware interfaces. It’s intended to be the base for a middleware method that you write, depending on what you want to happen when you detect that the visitor came from a search engine. In the example process_view method, I detect when the request is going to use the object_detail view and log the search query for that object in the database.
  • Jared Kuolt’s patch to allow Django’s shortcuts, get_object_or_404 and get_list_or_404, to accept QuerySets has been checked into Django as of revision [5796].

If you have any tips, project announcements, or generally interesting Django news, email me at clintecker+djangotips@gmail.com.

Django status update: July 22

July 22, 2007

  • Database migration has been the topic of the week with Mike Heald’s dbmigration tool for Django applications. Mike describes the project: “This project attempts to allow you to apply schema migrations to your Django applications in an automated way. It requires a little more up-front thinking than the schema evolution branches would make you do, but with the advantage that automated rollouts are much easier to do than in the standard Django trunk and the code is available and working right now.
  • Seemingly on the heels of Mike’s project, Derek Anderson, the author of the Summer of Code 2006 project schema-evolution, has updated his code to work properly with the 0.96 release of Django. Derek also states that the schema-evolution should work fine with the trunk version of Django as well.
  • Jacob Kaplan-Moss has generated a photomosaic of sites that are powered by Django. Check it out, it’s pretty interesting! Jacob says: “A collection of Django-powered sites collected from the wiki and djangosites.org. This mosaic has about 650 out of the list of over 800 collected from those sites. Compare with a similar mosaic I made last year. Also available: the super-high-quality original (PNG, 8000×6000, 38 MB).
  • Nathan Ostgard has written an article demonstrating how to implement an undo mechanism to your Django applications: “It’s a pretty simple concept: add a trashed_at field to your model, with the default value of None. When delete() is called on an object, if trashed_at is None, set it to the current time but don’t delete it. If it’s not None, actually delete it from the database.
  • Stockphoto is a photo gallery application written in Django: “It is designed to integrate into existing dynamic websites built with Django, to be easy to install, and to have few prerequisites, both in terms of third-party modules and in terms of expectations about site layout. It attempts to make maximum use of built-in Django facilities (authentication, admin pages, generic views) as much as possible in order to provide the simplest possible photogallery application while providing a reasonably full set of features.
  • The first Satchmo-powered online store came online this past week. Abode living is hopefully the first in a long line of stores running on top of the Django-based online store application. If you haven’t heard of Satchmo before, take some time to poke around their site. They’ve also got a helpful mailing list and very lively group of developers working on the project.

If you have any tips, project announcements, or generally interesting Django news, email me at clintecker+djangotips@gmail.com.

Django status update: July 15

July 15, 2007

  • Malcolm Tredinnick wrote in this week and wanted everyone to know that in [5708], a change was made to the translation framework that now requires all PO files to be UTF-8 encoded: “This change only affects third-party developers who are using Django’s make-messages.py script to extract their strings for their own PO files. The PO files will need to be saved and edited as UTF-8 files and the charset set correctly in the header of the file. All of Django’s core translation files already satisfy this requirement.
  • Peter Sanchez caught my attention with a post on his blog that details the process of pinging the Technorati search engine from Django. There are, of course, several other methods of doing this. If you’re interested in pinging Technorati, check out all three.
  • Not new, but not yet covered here is Christian Metts’ typogrify filter for Django. Jeff Croft, Christian’s co-worker at World Online, has an excellent write up of the filters on his blog. The project’s Google Code page describes itself thusly: “Typogrify is a collection of Django template filters that help prettify your web typography by preventing ugly quotes and widows and providing CSS hooks to style some special cases.” For the visual among us, Christian hosts an example page demonstrating everything the filters do.
  • Will Larson has written an excellent article on putting together a “dream server” for Django deployment: “The end product is an Ubuntu Feisty server using Apache2 and mod_python to serve Django, and lighttpd to serve static media. It uses memcached as its caching backend, and uses Postgres8.2 as its database. The machine built using these instructions is in fact running this blog, which is a Django application. I performed this installation on a SliceHost 256 meg slice, but they would apply equally well to any Ubuntu server (not so well to shared hosting).
  • Thejaswi Puthraya has updated the Google Summer of Code project, django-check-constraints, this past week. The SQL generation code that had previously been addded to management.py has been moved into the Check class and the whole project has been made compatible with the newly-available unicode friendly revisions of Django.

If you have any tips, project announcements, or generally interesting Django news, email me at clintecker+djangotips@gmail.com.

A great two years

July 15, 2007

It's our two-year anniversary!

Django was open-sourced exactly two years ago today, on July 15, 2005.

The past two years have been tremendous. If you're just starting to use Django, you're probably not aware of the huge improvements we've made since the framework was open-sourced:

Two years ago, we didn't have an internationalization framework.

Two years ago, models looked like this:


class Package(meta.Model):
    db_table = 'packages'
    fields = (
        meta.CharField('label', 'label', maxlength=20, primary_key=True),
        meta.CharField('name', 'name', maxlength=30, unique=True),
    )
    ordering = (('name', 'ASC'),)

    def __repr__(self):
        return self.name

Two years ago, we didn't have the render_to_response() shortcut. You had to load templates manually using get_template(), create a Context and call t.render(c).

Two years ago, we didn't have manage.py runserver. The only way to deploy, or even test, Django code was to set up mod_python! (We changed that pretty quickly.)

Two years ago, we didn't have a way to do sessions.

Two years ago, we didn't have support for database transactions.

But even more striking than these changes is the fact that the framework's general design has remained consistent. Despite loads of new shortcuts and functionality, it still boils down to URLconfs, models, views and templates. If you beamed in a Django developer from the year 2005 and showed her the July 2007 Django trunk, she would more-or-less understand how it worked.

Here's to the future. Thanks for using and improving Django!

Django status update: July 8

July 8, 2007

  • After several months of hard work, the unicode branch has been officially merged into trunk on July 4, 2007. The branch had been under constant development since April 7th, fixes a number of bugs, and makes Django fully unicode-friendly from top to bottom. For those developers tracking trunk, please be aware that there may be a number of changes you may have to make to your applications to keep them from breaking. For help, see the quick checklist for porting your applications to work well with the new unicode-friendly version of Django.
  • David Cramer, part of the development team over at Curse Gaming, has been involved in one of their internal projects that they’ve dubbed CacheManager. David leads off with the tease: “Tired of writing cache.set code?” The Curse team got tired of dealing with the relatively simplistic cache.get and cache.set methods that the Django caching framework exposes and built a friendly manager class to “store and retrieve cached objects.” The project also claims to help prevent data duplication as well as help you implement smart caching in your application with less headaches.
  • There have been several updates on the Google Summer of Code front this past week:
    • Jannis Leidel has been making progress on the django-package project. This project aims to make packaging and distributing Django applications as easy and pain-free as possible: “This week I continued to work on the “startapp” command of django.core.management and changed its default behaviour to create a standalone application (with skeleton files) when you run: “django-admin.py startapp myapp”. Current skeleton files are: release.py, setup.py, MANIFEST.in, docs/, test/, myapp/, myapp/templates/myapp…
    • Thejaswi Puthraya’s django-check-constraints project gained compatibility with the newly-checked-in Oracle code and is rapidly gaining doctests. The project’s Google Code page also gained a test project, complete with applications, readme files, install files, and screenshots of for those who were unable to watch Thejaswi’s screencasts.
    • Finally, Andreas Stuhlmüller’s django-rest-interface project is nearing a stable state: “The basic framework is done. If you feel experimental, give it a try and take a look at the RESTful API for your Django models, the serialized (JSON, XML) or templated output, the authentication mechanisms and the automatically generated URL patterns. Of course, I can’t give any guarantee that by the end of the SoC project any specific feature will still look like it does now—and I am fairly certain that it will be a lot easier to use custom URLs then than it is now.
  • In addition to the Django En Español and Django-FR user groups, there is also a Django Brasil group for Portuguese-speaking Djangoists. The group has been fairly active since December 2006 and shows no signs of slowing down!
  • Since our highlight of the new Django-powered social messaging application Pownce last week, the site’s notoriety and exposure have exploded. Mike Malone interviewed the lead developer of Pownce, Leah Culver, about Pownce’s roots as well as the technologies that power the site.
  • It’s a good bet that if you’re reading this post you’re at least a little interested in Django. Are you also interested Adobe’s cross-platform framework, Flex? If so, you might find Ian Millington’s Django and Flex blog to be very interesting.
  • This last bit isn’t strictly Django-related, but I think enough Django developers would be appreciative of Adrian Holovaty’s newest project, TemplateMaker. TemplateMaker is a Python library that takes any number of inputs, raw HTML for example, and learns which bits of that input are constant and which change from page to page. The end result is a template, with holes present where the dynamic content once was. I’m envisioning the endless uses of this library in my own Django applications. Read Adrian’s introduction of the project on his blog.

If you have any tips, project announcements, or generally interesting Django news, email me at clintecker+djangotips@gmail.com.

Django status update: July 1

July 1, 2007

This is the Django Status Report where we recap important happenings in the Django-verse and cool Django-related projects, presentations, publicity, code, and groups. Let's get on with the show:

  • Perhaps the biggest news this week was the launch of a new social network in the vein of Twitter. Pownce bills itself as a “way to send stuff to your friends.” Less succinctly, it is a social messaging Web application that lets you send notes, files, links, and events to your friends. There are a lot more features and tidbits, but that’s the basic gist. The site runs on Apache/mod_python and, of course, Django and Python. The principal developer of Pownce is Leah Culver, who has a post on her blog about the site. Currently the site is in an invite-only alpha phase, but they hope to open it up to the public in the near future. I've been using the service for the past few days, and while it's definitely in beta-phase and going through growing pains, the potential there is great. I think that the team behind this site can really grow it into a fun and useful site.
  • James Bennett has posted another super-useful set of libraries that stack on top of Django’s built-in comments application: “The big feature for this app is a generic, unobtrusive, extensible system for comment moderation which includes the ability to turn on any or all of the following options, on a per-model basis: Akismet spam filtering, auto-closing comments a certain number of days after an object’s publication, auto-moderating comments a certain number of days after an object’s publication, ...” There are actually a bunch more features built-in, so you’d be remiss if you didn’t go check out the page. James also informs us that also included with his comment_utils library are a set of “moderation-oriented template tags” and a “custom manager which can figure out the ‘most-commented’ objects of any model it’s used on.” Be sure to thank James for creating such a useful set of tools.
  • GeoDjango, the GIS-enabled branch of Django, will be featured in a presentation by Justin Bronn and Travis Pinney at FOSS4G2007 —Free and Open Source Software For Geospatial 2007—taking place in Victoria, Canada. The conference takes place between the 24th and 27th of September, 2007.
  • Django is going to have a big presence at the O’Reilly OSCON this month. OSCON takes place in Portland, OR from July 23rd to the 27th. Announced on the Django wiki by Paul Bissex is that there will be a Django Master Class tutorial at the conference presented by Jacob Kaplan-Moss, Jeremy Dunck, and Simon Willison. Be sure to add your name to the Django OSCON page linked above if you’ll be attending the conference.
  • I ran across an interesting middleware, SSL Middleware, this past week that allows you to specify in your urls.py file which paths in your application should be secured by SSL. If a user attempts to access one of these URLs through standard HTTP port 80, the middleware will intercept this access and redirect the client to the appropriate HTTPS protocol over port 443 and hopefully initiate a secure session. Users have reported that this doesn’t function 100% correctly on WebFaction’s setup and have produced a slightly modified version that operates properly there: link.
  • Finally, a new group has formed to foster growth in Django-related entrepreneurial ventures. The group describes itself as follows: “Django Entrepreneurs is for people using the Django web framework to launch a startup/online business; our activities will include discussion and sharing resources (technical and business) to further one another’s success. If you’d like to join this group, please send an introductory message to the moderators – our aim is to have a small, serious community of programmer-entrepreneurs who are supportive of one another.” The Google groups page is here: Django-Entrepreneurs