Reputation: 6304
Is it advised or redundant to set permissions on the template AND the view?
Consider that any data manipulation to the DB is done through POST
if the following enough for permissions?
{% if perms.system.view_employee %}
<!-- content here -->
{% else %}
<h1>Sorry you do not have permission to access this page<h2>
{% endif %}
or should I also implement server side checking as well (is it redundant to do so or necessary)?
def my_view(request):
if not request.user.has_perm('polls.can_vote'):
return HttpResponse("You can't access this page")
else:
# do stuff
...
Upvotes: 0
Views: 200
Reputation: 596623
Permissions checks in the template and in the view do not have the same purpose:
In your particular example, you must set the permissions checks on the view to dissallow anybody to do this manipulation. Usually, if the views is accessed using POST their are little chances you want template permission checks because POST requests are actions by essence.
You usually will want template permissions checks if you:
Upvotes: 6