JS+Django: streaming multi-part ajax responses (MXHR)

Ajax is great eh? What did it stand for again…? Asynchronuous Javascript And XML?

Anyone actually sending back XML in their Ajax app these days?

I find, if I have the choice, I’m using JSON for sending the data back. Then, for those times where you don’t want to duplicate all of the templating logic from the server in your Javascript code just to ‘Ajax’ a form or something, I find I will often render a bit of HTML and send that back, even if it feels a bit dirty. It’s easy and there’s a certain DRYness that’s undeniable.

So it’s only a matter of time before you start thinking, as a did, “Sure, I could make half a dozen separate XHR requests, but what I really need to do here is send back a package of identifiable HTML and JSON chunks.”

Read more of this post


Django: export CSV admin action

Just a quickie…

If you’ve ever needed this:

Then here’s some handy code to do that.

You can customise and use this action (actually a sort of action factory function) with any of your models which need it.