Python 如何在Django中从多值dict读取或保存文件

Python 如何在Django中从多值dict读取或保存文件,python,django,pandas,multi-value-dictionary,Python,Django,Pandas,Multi Value Dictionary,我正在把一个excel文件从Angular发送到Django。我想使用Pandas读取文件并在文件中执行一些操作,但我不确定如何执行 class fileupload(APIView) : def post(self, request): f = request.FILES print(f) 当我打印时,它显示在下面 <MultiValueDict: {'excelfile': [<InMemoryUploadedFile: New_Exc

我正在把一个excel文件从Angular发送到Django。我想使用Pandas读取文件并在文件中执行一些操作,但我不确定如何执行

class fileupload(APIView) :
    def post(self, request): 
        f = request.FILES
        print(f)
当我打印时,它显示在下面

<MultiValueDict: {'excelfile': [<InMemoryUploadedFile: New_Excel.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)>]}>

在这里,我想将该文件保存到某个位置,并使用pandas执行操作,或者如果可能,直接使用pandas读取该文件。我是Django和Pandas的新手,所以如果有什么问题,请帮助我。。提前谢谢

class fileupload(APIView) :
def post(self, request): 
    f = request.data.getlist("excelfile")
    print(f) # list of elements

现在循环f,然后逐个存储

嗨,我看到了<代码>[]。在此之后如何保存文件。。你能帮忙吗。感谢您获得内存对象列表,然后循环它,作为索引,枚举中的值(f):Tablename.object.cretae(attribute_name=value)
from django.core.files.storage import default_storage    
from django.core.files.base import ContentFile
file_objs = request.data.getlist('files')
for file_obj in file_objs:
    path = default_storage.save(settings.MEDIA_ROOT, ContentFile(file_obj.read()))
    print("images path are",path)