Added logic to views.py