Django returns 403 error when sending a POST request

后端 未结 7 2093
名媛妹妹
名媛妹妹 2021-01-31 08:27

when I\'m using following Python code to send a POST request to my Django website I\'m getting 403: Forbidden error.

url = \'http://www.sub.domain.com/\'
values          


        
7条回答
  •  无人及你
    2021-01-31 08:46

    I too had this problem, because I Tried to access the Main endpoint from another endpoint using '../url' URL Jumping. My Solution was to add another path for the same viewset;

    router.register('main/url',ViewSet,'name');
    router.register('secondary/url',ViewSet,'name')
    

    But in Your Case You are Trying to access it from a completely different Location, From Django's Point of view So You need to mark you ViewSet with @crsf_exempt middleware which will Disable Security Protocols Related to CRSF.

提交回复
热议问题