0
我想測試一個API後調用,它允許文件上傳,但我不能得到它的工作,我總是收到301Django的上傳文件測試返回301
with open('video.mp4') as f:
data = {'file': f}
response = self.client.post('/api/upload_file', data, format='multipart')
返回的響應是301
HttpResponsePermanentRedirect status_code=301, "text/html; charset=utf-8", url="/api/v1/assets/upload_file/"
我確保self.client進行身份驗證和測試的其餘部分正確
self.client = APIClient()
self.client.force_authenticate(user=self.user)