Add forbidden_view method adds the message and redirects to the same path

This commit is contained in:
M.Ravi 2017-10-01 20:17:03 +02:00
parent 9e8d930a3b
commit 167eaf2a0c

View file

@ -1136,3 +1136,15 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin,
bill.total_price += vm['price'] bill.total_price += vm['price']
context['vms'] = vms context['vms'] = vms
return context return context
def forbidden_view(request, exception=None, reason=''):
"""
Handle 403 error
"""
logger.error(str(exception) if exception else None)
all_messages = messages.get_messages(request)
messages.add_message(request, messages.ERROR, reason)
return HttpResponseRedirect(
request.get_full_path()
)