views.py refactoring