Modify structure of Django code