2

I am using Django and Django Rest Framework. When i used this view to delete user review on django server its working.

   @api_view(['GET','POST','DELETE'])
    @permission_classes((IsAuthenticated,))
    def user_reviewrating(request,websitename):
          if request.method == 'DELETE':
            try:
                snippets = website_review.objects.get(website_id = website_index.objects.get(slug=websitename).uuid,user_id__username = request.user.username).delete()
                return Response({"status":"deleted"})
        except :
            return Response({"status":"not deleted"})

But this is giving 403 Access Denied , Description: You are not allowed to access the document you requested. on apache server. Do I need to set any other permission for delete.

Network:

Response:

<HTML>
<HEAD>
<TITLE>Access Denied</TITLE>
</HEAD>

<BODY BGCOLOR="white" FGCOLOR="black">
<H1>Access Denied</H1>
<HR>

<FONT FACE="Helvetica,Arial"><B>
Description: You are not allowed to access the document you requested.
</B></FONT>
<HR>
</BODY>
Ashish Gupta
  • 2,574
  • 2
  • 29
  • 58

1 Answers1

0

Maybe you are logged out of the portal when you try to access the view. Try logging in and then hitting the url. That ought to sort your problem.

In case you are using Session Authentication, log into the portal using a browser and then use the REST Client/browsable API to access the url via a DELETE request.

Animesh Sharma
  • 3,258
  • 1
  • 17
  • 33
  • Yes i am using session authentication and I accessed the url via DELETE request and I am getting this error. And its working fine on local django server but not working on apache – Ashish Gupta Jul 12 '15 at 07:35
  • 1
    Sometimes, it so happens that PUT and DELETE requests are disabled in apache. Try turning them on. This link might be helpful. http://forums.phpfreaks.com/topic/143940-solved-put-delete-enabled-by-default/ – Animesh Sharma Jul 12 '15 at 07:46