0

基本上我的问题是这样的:我的目标是将用户输入的描述保存到一个文件中,该文件必须使用 ISBN 的名称保存

这是我的代码:

descr=request.POST['descr']
filename='/media/'+str(request.POST['isbn'])+'.txt'
f = open( filename, 'w+')
myfile = ContentFile(f)
myfile.write(descr)
myfile.close()

进入settings.py

MEDIA_ROOT = 'C:/Users/7/toplibrary/media'
MEDIA_URL = '/media/'

我不知道为什么,但它不起作用......有什么建议吗?

4

0 回答 0