Simon Willison’s Weblog

Subscribe
Atom feed for django

577 posts tagged “django”

The Django web framework.

2008

Django Unit Tests and Transactions. If you’re using a transactional database engine (MySQL with InnoDB, Postgres or SQLite) you can speed things up by running each of your unit tests inside a transaction and rolling back in tearDown().

# 7th July 2008, 2:14 pm / unittesting, unittest, python, django, transactions, innodb, mysql, sqlite, postgresql

Django File Uploads (via) Nearly two years in the making, Django’s file upload capacity has received a major (and backwards incompatible) upgrade. Previously, files were uploaded by default in to RAM—now, files larger than 2.5MB are streamed to a temporary file and extensive hooks are provided to customise where they end up—streaming to S3, for example.

# 1st July 2008, 5 pm / django, fileuploads, s3, uploads

Graphite. Real-time graphing package for server monitoring, similar to RRDTool. Created by the team at Orbitz, using Django and ExtJS for the frontend and Cairo to generate the graphs.

# 28th June 2008, 11:53 pm / graphite, cairo, orbitz, rrdtool, monitoring, graphing, django, python, extjs

CookBookNewFormsFieldOrdering. Handy tip—change the order of fields in a Django newforms instance by over-riding form.fields.keyOrder (since fields is a SortedDict).

# 27th June 2008, 1:02 am / newforms, django, python, tip

mod_rpaf for Apache. A more secure alternative to Django’s equivalent middleware: sets the REMOTE_ADDR of incoming requests from whitelisted load balancers to the X-Forwarded-For header, without any risk that if the load balancers are missing attackers could abuse it to spoof their IP addresses.

# 24th June 2008, 5:02 pm / django, middleware, apache, rpaf, modrpaf, security, xforwardedfor, http, load-balancing

Django snippets: Command to dump data as a python script. Extremely useful—dumps the data for an application as an executable Python script which will re-import it in to another database without any risk of colliding with existing IDs, sorting out foreign keys along the way.

# 24th June 2008, 12:07 pm / django, python, import, django-snippets

The basics of creating a tumblelog with Django (via) Ryan Berg suggests having a StreamItem model that links uses a GenericForeignKey to link to other content types, then using signals to cause a StreamItem to be created for every other model type. I should switch to doing that on this blog: at the moment I have to query three separate tables to build the tumblelog part which results in messy code for ordering and pagination.

# 24th June 2008, 11:09 am / ryan-berg, django, python, tumblelog, genericforeignkey, contenttypes

What is it like to write a technical book? Plenty of food for thought from the lead author of the new edition of High Performance MySQL. It’s amazing how Word is still an integral part of most technical book projects despite its obvious inadequacies compared to a toolchain based on plain text files and Subversion (the Django Book used ReST and Subversion to great effect).

# 20th June 2008, 8:18 am / writing, word, subversion, django, rest, plaintext, baron-schwartz

PortingDjangoTo3k. Martin von Loewis has started assembling a patch. His write-up illustrates some key differences between Python 2.X and Python 3—it looks like Django’s unicode handling is going to require the most work.

# 19th June 2008, 5:53 pm / python3k, python, martin-von-loewis, django, unicode

New foundation for Django. Django now has its own nonprofit software foundation (courtesy of a bunch of tough paperwork by Jacob Kaplan-Moss), and fittingly the Lawrence-Journal World get the exclusive.

# 17th June 2008, 5:16 pm / ljworld, django, python, jacob-kaplan-moss, dsf

DebugFooter middleware with Pygments sql syntax highlighting. Andreas Marr has enhanced my Django DebugFooter middleware with proper syntax highlighting for the logged SQL.

# 14th June 2008, 10:04 am / django, middleware, andreas-marr, debugfooter, python

Censoring the Internet at Paraguay. The state owned telecommunication company DNS hijacked the opposition party’s domain to point at a porn site during the election back in April. Maybe we don’t want a django.py vanity domain after all...

# 13th June 2008, 3:24 pm / paraguay, django, python, censorship, dns

RFC: Django 1.0 roadmap and timeline. Jacob’s proposed target is “early September” for the final 1.0 release.

# 12th June 2008, 10:34 am / django, python, jacob-kaplan-moss

Shortcutting render_to_response. I tend to use a simple wrapper function, but the other options described here are worth exploring. This is why I’m so keen on Django’s “take a request object, return a response object” philosophy—it makes it trivial to extend the framework in the direction you want.

# 10th June 2008, 11:49 am / django, request, response, python

Debugging Django, a slidecast. I used SlideShare’s slidecast tool for the first time to synchronize audio of my Django London User Group talk with the slides. The talk included several live demos which aren’t represented in the slides so it’s a bit piecemeal in places.

# 25th May 2008, 2:47 pm / debugging, slideshare, slidecast, django, speaking, djugl, my-talks

modswgi: Debugging Techniques. mod_wsgi is excellent software, and the documentation is equally superb. I used these instructions recently to run the Python debugger inside a running instance of Apache, which helped my track down some import errors that weren’t occurring with Django’s development server.

# 25th May 2008, 1:34 pm / modwsgi, django, python, debugging, pdb, wsgi

On-board vs. Off-board Comet. Useful distinction. On-board comet runs on the same server as the rest of your application; Off-board comet is served from a separate server (generally a subdomain) and a separate stack. If you want to stick with PHP, Rails or Django for the rest of your site off-board comet looks like the way to go.

# 22nd May 2008, 5:02 pm / comet, php, rails, django, joe-walker

Debugging Django

I gave a talk on Debugging Django applications at Monday’s inaugural meeting of DJUGL, the London Django Users Group. I wanted to talk about something that wasn’t particularly well documented elsewhere, so I pitched the talk as “Bug Driven Development”—what happens when Test Driven Development goes the way of this unfortunate pony.

The slides [... 1,759 words]

Django: security fix released. XSS hole in the Admin application’s login page—updates and patches are available for trunk, 0.96, 0.95 and 0.91.

# 14th May 2008, 7:49 am / django, security, xss, django-admin

Django admin OmniGraffle stencil. Alex Lee put together a beautiful stencil for OmniGraffle containing all of the common UI elements seen in the Django admin interface, as a tool for wireframing.

# 13th May 2008, 5:58 pm / alex-lee, omnigraffle, django, django-admin

django-db-log. Middleware that logs Django exceptions to the database, using a clever scheme based on an MD5 of the traceback text to group duplicate errors in to batches.

# 13th May 2008, 8:07 am / david-cramer, django, exceptions, logging, middleware, djangodblog

Byteflow Blog Engine. This looks like the most full-featured of the Django blog engines by a pretty big margin, including OpenID client and server support. A product of the growing Russian/Ukrainian Django community.

# 11th May 2008, 7:41 pm / openid, byteflow, django, python, russia

Django Users Group London meetup, 19th of May. The inaugural meeting of DJUGL will be on the 19th of May at the Capital Radio building in Leicester Square, sponsored by GCap Media. Three presentations starting at 7pm (I’ll be giving one of them), then on to the pub. Sign up on EventWax; there are only 70 places.

# 2nd May 2008, 12:19 pm / django, python, london, djugl, gcap, gcapmedia, events

jQuery style chaining with the Django ORM

Django’s ORM is, in my opinion, the unsung gem of the framework. For the subset of SQL that’s used in most web applications it’s very hard to beat. It’s a beautiful piece of API design, and I tip my hat to the people who designed and built it.

[... 820 words]

QuerysetRefactorBranch. What’s new and changed now that queryset-refactor has merged to trunk.

# 27th April 2008, 7:34 am / querysetrefactor, django, python

Multiple inheritance of newforms and modelforms. If you ever see “Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases” when trying multiple inheritance with newforms and modelforms, here’s a scary solution I found.

# 12th April 2008, 12:54 pm / django, python, multipleinheritance, metaclasses, inheritance, newforms, modelforms

Sharedance (via) “Sharedance is a high-performance server that centralize ephemeral key/data pairs on remote hosts, without the overhead and the complexity of an SQL database.”—ideally suited to session data, which is a poor fit for a full relational database.

# 12th April 2008, 10:39 am / sharedance, sessions, django

Active on IRC in the past hour. New Django People feature in collaboration with Brian Rosner—DjangoBot now provides information on currently active IRC participants. There’s an opt-out privacy control and the bot sends you a message about it the first time it logs your activity.

# 12th April 2008, 12:58 am / django-people, django, python, irc

django-rosetta—Google Code. Very classy Django-powered interface for both reading and writing your project’s gettext catalog files, hence allowing application translators to work through a web interface.

# 11th April 2008, 7:31 am / django, gettext, internationalisation, i18n, djangorosetta