Django: Refactoring and improvements