Django Cheat Sheet

Here are couple of useful commands / tutorials (in french sorry!) to get started easily with Django.

Create a project startproject <project_name>

Manually create a subfolder for HTML templates

Running servers

python runserver

Create an application (inside of a project)

python startapp blog


You should also read the Django course of Open Classrooms   to get started smoothly 🙂


Parsing errors – JSON

Parsing JSON with the jQuery method $.parseJSON can be tricky to debug, specially when you’re using a mobile device. Here are a list of errors I encoutered, and the reason why they were raised.

Unexpected token u
The method tries to parse a undefined variable.

Unexpected token o
The method tries to parse [Object object].

Sessions keep refreshing – CodeIgniter

I had a bug once, the sessions kept expiring even though the token was still valid.

I found out that CI_sessions were refreshing the session_id all the time. This was a database issue, be careful on the length of the columns in the database. The column that stored the session_id was too short and the token kept being re-generated since the old one couldn’t be recognized.

This was a tricky bug because it didn’t raise any obvious PHP error… Be careful with the schema of your database folks !

Best ways to debug Javascript

I was looking for an equivalent of PHP’s print_r to debug Javascript Objects and I found this very cool method:


How about you ? How do you debug objects in Javascript ?

Passing arguments in an event handler – Javascript

I had this problem while working on Leaflet but I think it can be generalized to the issue of passing parameters to an event handler in Javascript. With the “bind” method of jQuery, you can pass parameters by using the data property of event (the object sent when an event is triggered) :

$(marker).bind("click", { parameter : its_value, parameter2: its_value }, function(event) {
console.log("Your parameter is :" +;
console.log("Your parameter2 is :" +;
// your code goes here

As “marker” was a L.Marker object, I had to convert it into a jQuery object before applying the bind method. Thank you Anurag on StackOverflow !!

Connect a Gumstix via Serial – Eclipse Ubuntu

I was following this well-written tutorial to set up eclipse for my gumstix when I came to the part “Connect your gumstix” (with the Eclipse Terminal). Before setting up the terminal connection on Eclipse, make sure that Eclipse will have the permissions to access to the folder. I didn’t have the permissions and I had the error “/dev/ttyUSB0: No such folder error” even if my board was plugged.
A simple chmod on the folder resolves the issue. Make also sure that you have an UTF-8 encoding, otherwise you gonna have a bad time while reading what’s going on on your board ! 😀