drf处理文件
class Picture(View):
def post(self,request):
username = request.POST.get('username')
fafafa = request.FILES.get('fafafa')
print(username, fafafa)
print(fafafa.chunks())
with open(fafafa.name,"wb") as f:
for i in fafafa.chunks():
f.write(i)
ret = {'code': True, 'data': request.POST.get('username')}
data = {
'id': 1,
'name': 'zhangsan',
'method': 'POST'
}
return JsonResponse(data)