1👍
✅
You can obtain the logged in user with request.user
, so that means that we can work with:
from django.contrib.auth.decorators import login_required
@login_required
def home(request):
template = 'home/home.html' if request.user.profile.is_teacher else 'home/tutor_home.html'
return render(request, template)
Note: You can limit views to a view to authenticated users with the
@login_required
decorator [Django-doc].
Source:stackexchange.com