Migrate to django 1.7

Fix some improtrs toat make the code work in django 1.7.