title: How to Raise Error on @permission_required decorator in Function Based View
body: <p>How to raise an error message if permission_required is failed on Function Based View?i want to raise error message instead redirect to login page, i know how to raise an error message in CBV but i don't know how to raise it in Function based view, Please Help Me.
  Thanks and here is a code.</p>
  
  <pre class="lang-py prettyprint-override"><code>@permission_required('request.user.projectuser.change_projectusermodel')
  def update(request, id):
      test = User.objects.get(id=id)
      try:
          second_form = UpdateAccountDetailForm(request.POST or None, instance=test.profile)
      except:
          second_form = UpdateAccountDetailForm(request.POST or None)
  
      try:
          third_form = UserRoleForm(request.POST or None, instance=test.roles)
      except:
          third_form = UserRoleForm(request.POST or None)
  
      if request.method == 'POST':
          form = UsersForm(request.POST, instance=test)
          form2 = second_form
          form3 = third_form
      else:
          form = UsersForm(instance=test)
          form2 = second_form
          form3 = third_form
      return save_all(request, form, form2, form3,'projectuser/update.html')
  </code></pre>