Save the ions!

Introducing django-exportateur

Exportateur?

OK, this article is a bit late, but I think it’s still necessary to properly introduce a new project.

At work last week, I had to write a generic way of exporting a QuerySet to csv, ods, and maybe some other format later on. Since I work at AUF, I frenched up the project’s name.

Why start from scratch?

I’m pretty sure that there already are a few apps that do that, but since I still consider myself kind of new to django, I thought it would be a good learning exercise to write this app myself.

The idea

The files I had to generate needed to have a header that described each column, and the values needed to be clear (no ids, etc.)

I decided to add a method to get the object’s fields (attribute name as well as verbose name), and another one to get the attributes’ values. That’s pretty much it for the Django part.

The last part of the project was to define a generic-enough method to export those fields in the file format we want. The file format is passed as a parameter so that it can be passed directly from the url.

Have a look

The code is now published on code.google.com. Feedback is always welcome.

Leave a Reply