I’m using django for a web project
I wan’t to render a page for unauthenticate users and one for authenticated.
Is it better to define this directly in my view :
def get(self, request, *args, **kwargs):
if not request.user.is_authenticated:
return render (request, 'unauthenticated.html')
else:
return render (request, 'authenticated.html')
Or use only one view, but root them in my template :
def get(self, request, *args, **kwargs):
return render (request, 'index.html')
<!-- index.html -->
{% if not user.is_authenticated %}
{% include "unauthenticated.html" %}
{% else %}
{% include "authenticated.html" %}
{% endif%}
(My question is about both security and implementation)
New contributor
FormindMPO is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.