Weblog

Latest entries

Springtime for Django

Spring has returned to the northern hemisphere, and everything's coming up Django. Here's a rundown of what's going on in the wide world of Django:

PyCon 2008 (March 14-16, with sprints the following week) in Chicago had a healthy Django contingent; the official "Birds of a Feather" session was packed, as were the two Django tutorials held the day before the conference and the four Django-related talks during the main conference session:

  • Adrian Holovaty's "State of Django" talk covered the past year's progress in Django development, some of the upcoming features to be found in two development branches of Django (queryset-refactor and newforms-admin, which will be refactoring and incresing the power and flexibility of the Django object-relational mapper and admin interface, respectively), and also announced a new, nonprofit organization dedicated to Django: the Django Software Foundation. The paperwork is still pending, but once it's up and running the DSF will be a major resource for the community, helping to promote and organize the development of Django.
  • Marty Alchin's "Django Under the Hood" (slides are online) took a peek at some of Django's internals, and covered useful tricks and techniques any developer of a Django-based application can benefit from.
  • Steven Wilcox's talk on the Django admin (full text is online) included a tutorial on newforms-admin, showing how Django's admin application will work once that branch is completed, and hinting at some of the added functionality you'll be able to access when it lands.
  • James Bennett covered best practices for developing reusable Django applications (slides online), culling tips and patterns from two years of full-time Django work at World Online.

Slides from the two three-hour Django tutorial sessions are also available:

  • Jacob Kaplan Moss' Introduction to Django provides a fast-paced intro for developers who are new to Django.
  • The Django Code Lab, chaired by Jacob, Adrian and James, provided an opportunity for developers to submit code and questions, and get advice and critiques from three seasond Django developers.

After the conference proper, the week-long sprint session yielded a lot of development activity; though there was plenty of code checked in during the sprint, the big win at a conference like PyCon is the ability to get developers together in a room to talk about features and hold design discussions that might otherwise involves weeks of back-and-forth posts on the developers' mailing list. Some highlights of the sprint were discussions for newforms-admin and for model-level validation to complement and improve the validation Django's form library offers for web-based input.

In addition to the fun of PyCon, there's been a flurry of interesting Django-related activity in the past few months:

  • One of Django's lead developers, Jacob Kaplan-Moss, has moved on to a new job where he's getting paid to work on Django. Most recently, he's been leading an effort to migrate Django's documentation onto the Sphinx documentation engine, the same system that powers Python's own development documentation.
  • Simon Willison launched Django People, a network of Django users, developers and fans around the world. At the moment, there are almost two thousand people listed.
  • Ryan Berg launched Djangofriendly, a site which lists Django-friendly web-hosting services and lets users rate and review their hosts.
  • Revyver launched Django Pluggables, a catalog of publicly-available Django applications which, in its own words, does the work of tracking all those applications so you won't have to. They've got over a hundred applications catalogued already, and more are popping up all the time.

And, of course, Google announced App Engine, a massively-scalable application hosting service which debuted with support for developing and hosting Python applications on Google's distributed infrastructure, taking advantage of the same BigTable database engine that powers Google's own web services. And Django is available right out of the box.

Meanwhile, Michael Trier has revived the tradition of weekly Django roundups, and launched This Week in Django, a podcast which has regular interviews with interesting folks from the community, useful tips for application developers and weekly summaries of Django development activity.

And if you prefer your Django in dead-tree format, there are two books already on the shelves:

And two more have been announced:

Both are scheduled to be published this summer.

Also this summer, O'Reilly will be holding OSCON 2008 in Portland, Oregon; as always, expect to see a contingent of Django developers and users hanging out, meeting up and talking Django.

In the meantime, Django development will keep on rolling; if you'd like to help out, check out the documentation on contributing, hop onto the django-developers mailing list or the development IRC channel, and join the fun.

Posted by James Bennett on April 12, 2008

Django at PyCon

Ah, Spring... that wonderful time of year when flowers bloom, birds and bees provide useful euphemisms for tongue-tied parents, and Python hackers everywhere converge for the annual Python Conference

That's right: PyCon 2008 is only two short months away! This year's conference will be held in Chicago, and features a fantastic line-up of talks about everything Python. PyCon really is a wonderful conference, and early-bird registration is only $225 ($125 for students). I can't recommend the conference highly enough.

Of course, Django will be very well represented at PyCon, with activities for Djangonauts of all skill levels:

I'll be teaching a Beginning Django tutorial aimed at folks just getting started with Django. In past years this tutorial has filled up rapidly, so if you'd like to attend I recommend signing up soon.

Also on the tutorial day will be a Django "Code Lab" designed for people with some Django projects already under their belts. We've got a great panel of experts lined up to critique and improve your code: Adrian Holovaty, James Bennett, and yours truly.

[I should point out by way of disclaimer that I get a bit of money for teaching the tutorials. I'd promote them here anyway, of course, but I mention the compensation by way of full disclosure.]

The conference proper will feature a number of Django sessions:

  • Developing reusable Django applications (James Bennett)
  • Django: Under the Hood (Marty Alchin)
  • The Power of Django Admin (Even For Non-Django Projects) (Steven C. Wilcox)

Adrian will also deliver a "State of the Django" talk to discuss where the project is, and where it's going.

Finally, after all the talks end, we'll hold a four-day development sprint. Anyone interested in working on Django is encouraged to attend, and note that the sprints at PyCon are open to anyone, not just PyCon attendees. So, if you're in Chicago feel free to stop on by!

I hope to see a bunch of Djangonauts at the conference. I've been to PyCon for the last few years, and it's always been fantastic. I can see from the line-up of talks that this year will be no exception.

Remember to register before Feb. 20th to take advantage of the early-bird rates!

Posted by Jacob Kaplan-Moss on January 21, 2008

Media Temple offering Django beta program

The folks at Media Temple, who are kind enough to donate hosting for this djangoproject.com site, have launched a beta version of Django support in their "Grid-Service." They're looking to get beta feedback before doing a full release and are giving away free copies of the Django Book to the top 25 forum contributors who have a live Django application running on the service.

Here's where you sign up to help with beta feedback -- the only prerequisite is that you have a Grid-Service account.

Posted by Adrian Holovaty on January 12, 2008

The Django Book is done.

The Django Book started shipping last week, and we've put the full text online for free.

We put a draft of the book up about a year ago for comments, and were amazed by the quality (and quantity!) of responses. We read each of the comments (around 2500) as we revised the book towards a final print release. That print release has been available in stores for about a week, and we've put the text up for you to read for free.

As with the draft, we're soliciting comments which we'll use as we continue to revise the online text. We're also collecting errata from the print edition if you notice mistakes there.

We're immensely grateful to everyone who helped make this book happen.

Thanks also to Media Temple: we're now hosting the book site on machine they donated to the project a few months ago. Thanks, guys -- you rock!

PS: If you're not seeing the new book, it's probably because the DNS change hasn't propagated yet. Try new.djangobook.com in the meantime.

Posted by Jacob on December 16, 2007

Join us for our second worldwide sprint

We had such a great time doing that last sprint, so we're doing it again!

We'll hold the sprint Saturday, December 1st here in Lawrence, KS, and virtually around the world. We'll run things much the same as we did last time around.

We plan to devote at least 24 hours of focused work to get some of this done in an organized fashion, and also to encourage new people to contribute. If all goes well on Saturday, we'll probably continue to Sunday.

Anybody can participate and contribute, and there's no obligation or expectation. If you've never contributed to Django before, this is the perfect chance for you to chip in.

More information is available on the wiki.

Most participants will likely be working from their own homes/offices in their respective countries, but if you'd like to come hang out with us in Lawrence, email jacob -at- jacobian -dot- org. We can provide transportation to/from the Kansas City airport (MCI) and can recommend a good hotel in town. Also, a limited amount of free lodging (i.e. our couches) is available.

All participants -- not just those meeting in person -- should feel free to add their names to the wiki page.

Posted by Jacob on November 7, 2007

Security fix released

Today we're releasing a fix for a security vulnerability discovered in Django's internationalization framework. The complete details are below, but the executive summary is that you should updated to a fixed version of Django immediately.

We are releasing point-releases of all affected Django versions. You can download them at http://www.djangoproject.com/download/. Those tracking trunk development should "svn update" as soon as possible.

Please direct any questions about this release to django-users (http://groups.google.com/group/django-users).

Description of vulnerability

A per-process cache used by Django's internationalization ("i18n") system to store the results of translation lookups for particular values of the HTTP Accept-Language header used the full value of that header as a key. An attacker could take advantage of this by sending repeated requests with extremely large strings in the Accept-Language header, potentially causing a denial of service by filling available memory.

Due to limitations imposed by Web server software on the size of HTTP header fields, combined with reasonable limits on the number of requests which may be handled by a single server process over its lifetime, this vulnerability may be difficult to exploit. Additionally, it is only present when the "USE_I18N" setting in Django is "True" and the i18n middleware component is enabled*. Nonetheless, all users of affected versions of Django are encouraged to update.

Affected versions

  • Django trunk prior to revision [6608].
  • Django 0.96
  • Django 0.95 (including 0.95.1)
  • Django 0.91

Resolution

New versions of Django containing this fix have been released today which alter this caching mechanism to store shortened, normalized values and to reject improperly formatted headers.

These versions are called:

  • Django 0.96.1 (replaces Django 0.96)
  • Django 0.95.2 (replaces Django 0.95.1)
  • Django 0.91.1 (replaces Django 0.91.1)

Anyone using a stable Django release should upgrade to one of these point releases immediately. These fixed versions have already been provided to maintainers of Django packages for various OS distributions and should be released shortly.

Anyone tracking Django's trunk development should use Subversion to update to at least revision [6608].

Additionally, these fixes have been committed to the various "bugfixes" branches:

Anyone running custom versions of Django should download and apply the patches directly. These patches are available at http://media.djangoproject.com/patches/2007-10-26-security-fix/.

* This post originally failed to mention that the i18n middleware component must be enabled to trigger the bug.

Posted by Jacob on October 26, 2007

Django roundup: October 7

After a short hiatus, the Django Roundups are back! Lets not waste any time and dive in:

  • Django news:
    • The Django Sprint that took place last month looks as if it went off without a hitch. Adrian Holovaty documented on the Google Code Blog the tremendous level of activity that took place over the course of a single weekend: “The sprint was intensely productive, with more than 400 tickets closed in the Django issue-tracking system, 300 new patches/ticket attachments and more than 200 commits to the Django code base. All told, there were more than 2,440 changes, including wiki changes, ticket changes, patch uploads and code check-ins.
    • Simon Willison has published another set of slides in his Advanced Django series. This version is nearly identical to the previous with a new section on newforms.
    • Siddhi Govindaraj has created a second Django tutorial in screencast format. Siddhi’s second video expands on the wiki application from his first video by adding wikkiwords and search capabilities.
  • Projects of note:
    • Django Gigs has launched and serves as a single place to find work as a Django developer, and for employers to find highly-qualified programmers who are proficient with Django.
    • James Bennett has updated his excellent django-registration application to version 0.3. This update adds a more customizable email subject line, configurable form classes, configurable templates, a maintenance script to clean out expired user accounts, expanded documentation, unicode updates, and locale support.
    • Django on Jython work has continued over the past month or so with additional strides made toward total compatibility. Leonardo Soto Muñoz provides a roundup of advancements as of September 13, 2007. Frank Wierzbicki, lead developer of Jython, is also maintaining a document of the current gaps between Django and Jython.
    • What The Form is an extension for Django’s newforms that allows a developer to design how the form will be displayed to the user. Meta attributes like fieldsets and columns can be defined by the developer within their models and can be nested as much as necessary.
    • Björn Kempén has launched a Django-powered BitTorrent tracker he calls Geektorrent.
  • Code snippets and tutorials:
  • New user groups and other miscellaneous news:

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

Posted by Clint Ecker on October 7, 2007

I left my server in El Segundo

If you're reading this, then you're looking at the new home of djangoproject.com.

Django's adoption has skyrocketed over the last six months or so, and with the added popularity has come increasing traffic to this site —€” we're doing close to eight million hits each month, and growing. While the increased interest couldn't make us happier, it made the old, cranky server running the site incredibly upset. Over the past weeks we've been looking around for a new home, and I'm glad to say we found it:

mediatemple

About a month ago, Media Temple generously offered to take up hosting our site. They've given us a screamingly fast dedicated server, free hosting, and wonderful support. Even better, this is only Media Temple's first step into the wonderful world of Django; they've got some very cool Django hosting plans coming in the near future.

We're very excited about the things we'll be able to do with our new, more powerful server. In fact, we've already started: this weekend, Matt Croydon and Joe Heck set up the Django Buildbot which has already helped us catch a few nasty bugs. We're really looking forward to finding other areas in which our newfound power can help us develop Django faster and better.

So, once again, a big thanks to Media Temple —€” and especially Chris Lea —€” for their support.

Bonus points to anyone who gets the reference for the title...

Posted by Jacob on September 17, 2007

Join us for a worldwide sprint

On Friday, Sept. 14, 2007, we're going to hold a worldwide Django sprint -- an excuse for people to focus their undivided attention for a full day (or two) on improving Django.

We've got a bunch of features that are almost done but haven't yet been committed/merged -- including newforms-admin, ORM aggregate support, multi-DB support and GeoDjango. Plus, we've got almost 1,000 open tickets in our ticket system. We plan to devote at least 24 hours of focused work to get some of this done in an organized fashion, and also to encourage new people to contribute. If all goes well on Friday, we'll probably continue to Saturday.

Anybody can participate and contribute, and there's no obligation or expectation. If you've never contributed to Django before, this is the perfect chance for you to chip in.

More information is on the wiki page.

Most participants will likely be working from their own homes/offices in their respective countries, but a few of us in the U.S.A. will be meeting in person for more effective communication and momentum. We have tentative plans to congregate at the Google offices in Chicago and the main Google headquarters in Mountain View, California -- but in order for those plans to be firmed up, we need to provide a realistic headcount to the Google folks. Hence, if you're available to sprint and want to join us in person from either Chicago or Mountain View, please let me know as soon as you can.

All participants -- not just those meeting in person -- are encouraged to add their names to the wiki page.

Posted by Adrian Holovaty on September 6, 2007

Django roundup: August 26

  • Django sites and projects of note:
    • Satchmo is a robust web shop application written purely on top of Django. The Satchmo project hit a major milestone in its development this past week with version 0.5 (tarball) hitting the virtual shelves. Some highlights from the release notes: “100% template driven design using the django template system, integration with authorize.net, Paypal and google payment processing systems, flexible product management, PDF creation of invoices; packing slips and mailing labels, flexible tax; shipping and discount modules, newsletter management support including mailman integration, account management features” Congratulations are in order for the hard-working Satchmo team, they’ve been working on this release for quite a while!
    • Matt Waite wrote in this week about the most recently Django-powered application he’s developed for his employer, The St. Petersburg Times. It’s called PolitiFact: “It’s a Django driven take on the old newspaper “truth squad” story. We’re taking things the presidential candidates are saying during the campaign and fact checking them. All of them get put into our databases, and users can browse by all kinds of different things.” Matt has more to say about the application, PolitiFact, on his blog.
    • Justin Driscoll also wrote in about his new Django Google Code projects. The first is django-pressroom which serves as a complete public relations section for your site, complete with articles, photos, galleries, and file attachments. The next application was abstracted out of django-pressroom’s photo gallery functionality. This application is named django-photologue and should be a perfectly suitable photo gallery for any Django application you’re already working on. On what makes his applications special, Justin had the following to say: “The highlight of both apps (in my opinion) is the ability to specify PhotoSizes in the database. These PhotoSizes define the dimensions and parameters of resized copies of the uploaded image that will be generated from the source image and cached upon first request. If the PhotoSize is changed or deleted these cashed versions are removed. In addition, methods are added to the Photo model at runtime to access the cached images such as ” photo.get_mysize_url()” where “mysize” is the name of a defined PhotoSize in the database.
  • Code snippets and tutorials:
    • Joe Heck, driven by his experiences at OSCON, has developed a local queueing service in Django, django-queue-service. Joe wanted to provide a foundation for a tool that would help developers queue background tasks from their Django applications in a fashion similar to Amazon’s Simple Queue Service: “At OSCON 2007, I was hunting around for something to use to deal with background processing initiated from my web application. Not finding anything that I could immediately use and implement, I took it as a challenge to knock out something in the time I was there. The result is the django queue service.
    • Since Jacob’s initial success at getting Django installed on the iPhone, Jay Baird has been hard at work documenting the process as well as developing an application for the device: “The most intriguing [idea] to me has been the use of django as a full fledged framework for on/off-line applications where edge network usage just seems silly… I’ve been working on an online flight database for a while now and decided that it’d be cool to create an iPhone application that does the same that can sync with the main database when we become connected and want to push these records up.
    • Björn Kempén has developed a very simple middleware-based IP banning solution: “I wanted a simple way to ban users from accessing one of my django made homepages, and then having them redirected to a page with an explanation why. The IP’s and explanations should be entered through the django admin interface. For this django middleware is a decent choice.
    • If you use Mint for analytics on your site, you might be interested in Maura Chace’s post, Minty Django. Maura was interested in being able to view her website statistics along side all of the data in her custom-built Django weblog. In the post above, she details the process she undertook and the two small issues she encountered.
    • Thanassis Tsiodras has an excellent and in-depth tutorial on how he was able to build an offline Wikipedia browser using Django as the front-end.
    • Frederik Lundh moved his site, effbot.org to Django a few weeks back and has now posted some useful snippets of code that he’s developed for monitoring his memcached instance.
    • James Tinksy has posted a tutorial on paginating filtered query sets in a generic view: “I’m no Django expert. Hopefully someday I can call myself one but for now I’m stumbling through learning the basics. Most of it’s deceptively easy once you grok the concepts. You see I come from ASP classic and PHP 4 world where spaghetti code is the norm. In other words, I wasn’t groking the simple, elegance of Django.” James wasn’t kidding when he said this tutorial’s name packed a mouthful, but it doesn’t make the content any less interesting or useful; James does an excellent job of detailing his thought process throughout the article.

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

Posted by Clint Ecker on August 26, 2007

Django roundup: August 19

  • Django project news:
    • Adrian Holovaty proposed and ultimately implemented a new feature this past week that greatly enhances the process of developing your Django application. Summarized greatly, Adrian’s opening post put it like this: “wouldn’t it be useful we made it easy to run the Django development server with fixture data?” The new django-admin.py command, --testserver, is implemented as of revision [5912] and allows developers to load the development server with a test (temporary) database, populated with a set of fixture data. There's a bit more going on with this command that's detailed in the documentation.
    • On quite the roll this week, Adrian also spearheaded a re-factoring of the django.core.management code in [5898], converting the previously 1700+ line python script into a package that will eventually allow developers of 3rd party applications to add management functions without patching core Django code. Currently the existing code has been refactored and initial documentation can be found in the SVN repository at this time. There are still a few minor bugs to be ironed out, but all signs point to this change being a blessing for 3rd party developers.
    • The Google Summer of Code program is coming to a close today (Monday, August 20). This will mark the point at which students will be able to commit their code for inclusion in Django (if necessary) and allow external developers to work on their projects. In this session, Django had four student developers working on projects. Keep your eyes peeled over the next few days and weeks for the students’ final official updates. Certainly, and hopefully, many of these fine individuals will go on to maintain their projects and perhaps become regular contributors to the Django community. If you’ve foundtheir projects useful, please be sure to thank them for their hard work and contributions. I’ve taken this opportunity to list and summarize each of the projects below:
  • New Django sites of note:
    • Technically, I ran across this site last week but through some sort of technical blunder, it escaped my roundup. Noonhat is a Django-powered site that lets you meet people in your area for lunch. You make an account, associate an email address, pick a geographical location, and specify a radius in which you’d be willing to travel for lunch. If another user’s circle intersects yours, and your availability matches up, you can be paired for a lunch. The point behind Noonhat is to help nearby people meet each other and have conversations with individuals whom you might not normally ever meet under normal circumstances.
    • Marco Gabriel contacted me this week to let me know that he and Open Source Publishing Germany will be producing a German-language Django book, Django. Einführung in das Django Web Framework. Marco has also begun work on djangobuch.de which is a German language website to compliment the publication. Marco would also like to hear about any efforts to organize a German Django community (i.e. djangoproject.de) in the vein of Django Brasil, Django en español, Django-fr, and Django Japan.
  • Code snippets and projects:
    • A natural consequence of iPhone hacking is the installation of Django. Jacob Kaplan-Moss did just that. The iPhone uses CoreData for almost all of its storage needs and thus nearly all the information stored on the iPhone is inside SQLite databases. Pairing this information with a local install of Django and the inspectdb functionality allows anyone to create a web interface capable of viewing and editing anything on the iPhone. Jacob has yet to document his accomplishment in detail, so you’ll have to settle for Flickr. Django ‘It worked!’ screen on iPhone. Parsing the iPhone’s SQLite databases in Django.
    • Tim Baxter has posted a method on his blog for generating microformats—specifically vCard—using Django: “If you use Django, it seems inevitable that the database will quickly have a lot of data that just lends itself to microformats, particularly calendar events and contact information. So, I’ve been playing around with microformats quite a bit lately and spitting out hcalendar and hcard microformats all over the place
    • One of the holy grails of content management is a dead-simple method for capturing and displaying a list of every change made to your data. This can now be implemented almost perfectly (there are a number of missing features, most notably relationships) in your existing Django application with only a single line of code in your Django model. Check out the AuditTrail page in the wiki for more explanation, code, caveats, and documentation.
    • Bruce Kroeze has posted a lighttpd configuration on his blog that allows developers to serve their Django application through both standard HTTP and SSL-enabled HTTPS without any troubles. This is an especially important thing to get right when deploying a shopping cart application like the Satchmo Project.
    • The 10percentofeverything.com blog illustrates how you can easily interact with your Django application from command line scripts: “Sometimes, I need to write command-line scripts to populate a database with information from some other source, like a webpage or third-party database. Since Django uses MySQL (among others) for its backend storage, it’s fairly easy to use Perl or any other language for this task. Problem is, it’s very boring and fiddly, so now I tend to use Django instead, which is really easy.
    • Linux Journal, a monthly magazine, has published an article on getting started with Django: “It would be misleading to say that Django is a Python port of Rails (or vice versa)... Both aspire to make Web development fun and easy, removing as much of the drudgery as possible from such work. Both use the model-view-controller (MVC) paradigm for handling actions and creating pages. Both use a particular programming language throughout the system for code and configuration files. And, both have managed to rally a large following, ensuring that they both will continue to be developed for some time to come.

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

Posted by Clint Ecker on August 19, 2007

Django roundup: August 12

  • Django news:
    • Browsing through the repository checkins for trunk, I noticed that Malcom and Adrian had checked in over 50 patches for mostly bug-fixes to both code and documentation. If you’ve been waiting for a specific fix, take a look through the list. Thanks to everyone involved in working to get those 50+ patches integrated into trunk!
  • New Django sites of note:
    • Fredrik Lundh, maintainer of effbot.org, is currently porting over the "zone" (where things like PIL, Tkinter, and more are documented) to Django: “All in all, the zones at effbot.org currently contain around 2,000 documents, plus a couple of hundred user comments. Until now, the zone has been served as static HTML, generated and maintained using an increasinly disorganized collection of CGI scripts and off-site tools. Given that we moved pythonware.com to Django late last year, it’s about time I did the same to effbot.org.” Fredrik has written up his experiences during this process in a document which I highly recommend.
  • Code snippets and projects:
    • Maximillian Dornseif has posted a method for determining code-coverage of your Django project’s tests without having to alter any of the Django internals: “Siddharta Govindaraj has a blogpost on integrating Django with coverage.py to check what your tests actually test. Siddharta patches Django to archive his goals. But you can get the same results without fiddeling with Django’s Source-Code. Django now comes with a TEST_RUNNER setting which let’s you switch your testing engine.
    • Massimo Scamarcia sent me an email about his blog post that explains how you can create a basic Django-powered photo gallery in only a few minutes.
    • Michael Trier points us to a few different techniques for peeking inside Django’s ORM to see what database queries your application is generating.
    • Ross Poulton has written a blog post detailing how to configure and use subdomains with your Django project: “As a part of my previously mentioned upcoming bridal gift registry project (which, by the way, performed outstandingly in it’s most important private beta ever – my own wedding) I’m giving each user (in this sense, a user is a couple close to getting married) their own subdomain off of the main website – instead of having a URL to their registry like http://yourdomain.com/registries/view/?id=1048 there are beautiful URL’s like http://couplesnames.yourdomain.com.
    • Do you ever find yourself writing the same lines of code at the top of your views? Nathan Ostgard did and he’s such a dedicated DRY’er that he wrote a specialized middleware to clean up his code: “Having the same few lines at the top of every function in makes me feel dirty. You can clean this up with a Middleware class, replacing foo_id with the actual object before calling the view.” If you find yourself in the same situation as Nathan, head over to his blog, read his post, and hopefully make use of his middleware!

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

Posted by Clint Ecker on August 12, 2007

Django weekly roundup: August 6

Starting with this week I've begun formatting this report a bit differently. The order of these sections are quite arbitrary and may change from week-to-week as I find out which work out on a consistent basis. Feel free to comment on the new format in the comments below.

  • Helpful articles and links:
    • Michael Trier has written a lengthy article on his blog detailing some of the common issues people run into with Django’s syndication framework. He then describes a process you can follow to successfully get your feeds up and running.
    • Digging through items in del.icio.us tagged with ‘django’, I ran across this nifty Google search that returns a listing of all Google Code projects with ‘django’ in the title. Of course, I found a lot of known projects, but it was interesting to see all the others that don’t get publicized as often.
  • Code snippets and projects:
    • Last week we let everyone know that James Tauber had begun his work on fully fleshing out Atom support in Django. Less than a week later and James has completed his work. Check out James’ implementation of RFC 4287 for Django at its Google Code repository.
    • A newcomer to the Django community known only as ‘mamcx’ has begun the work necessary to complete the MSSQL backend. This backend had been left in a state of disarray as its original maintainers lost interest and the core of Django evolved over the past few years. Mamcx has already put in considerable work, but is somewhat new to Python and Django, so any assistance would obviously be much appreciated! Check out [5062] for his patches and comments.
    • Here’s a method of defining a set of URLs in your Django project that will never get cached.
    • Derek Willis has implemented iCal feeds in his Django application and written a subsequent post detailing how you can do it too. Using the excellent vObject library in tandem with Django (and applying a few idiosyncratic tweaks to make IE/Outlook happy) is very simple and eliminates the need for the developer (i.e. you) to develop any iCal templates!
    • Bradley Whittington has a series of posts on his blog that detail his development of a Django middleware to log statistics about users to a database. Part one details the construction of a data model to hold this information and how to log this information within a middleware component. Part two goes over one process by which you can aggregate this data in meaningful ways.
  • New Django sites of note:
    • FrePPLe came to my attention through a user-submitted email. FrePPLe is a specialized application for production planning in the manufacturing industry. It was described to me thusly: “A first part of it is an extensible planning engine written in c++ (with bindings exposed in Python). The second part is the user interface and data persistence layer. For this I have become excited about django: Django’s flexible and efficient framework provides the ideal foundation. Also, the Django mindset and design principles match very well with the easy-to-extend, easy-to-customize and easy-to-use goals of my project.” Check out the screenshots of FrePPLe and see how they’ve put the Django admin interface to work in some interesting ways.
    • Splice is an web application that allows users to upload, edit, and mix their music, as well as connect musicians from all over the world. Not only is this a really cool idea for a web site, it has a great design, and it’s written in Django!

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

Posted by Clint Ecker on August 6, 2007

Django weekly roundup: July 30

  • 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.

Posted by Clint Ecker on July 30, 2007

Django status update: July 22

  • 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.

Posted by Clint Ecker on July 22, 2007