【发布时间】:2017-10-18 03:21:01
【问题描述】:
我正在尝试测试允许文件上传的 API 发布调用,但我无法让它工作,我总是收到 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)
【问题讨论】:
标签: django django-rest-framework django-testing django-unittest django-tests