Django query optimization

shape