[英]Django Issues with Uploading a Python File
My code so far: 到目前为止,我的代码:
from django.core.files import File
file = open('ChicagoTimesScores.py')
djangofile = File(file)
myfile = File(file)
myfile.save('new', djangofile)
file.close()
I'm aware of repeating myfile, but I was a bit lost and tried what I could to see if it work. 我知道要重复myfile,但是我有点迷茫,尝试了我能看到的效果。
My error code: 我的错误代码:
Traceback (most recent call last):
File "C:/Python33/TestRun.py", line 6, in <module>
myfile.save('new', djangofile)
AttributeError: 'File' object has no attribute 'save'
I'm trying to save this python file with django, but it appears that python doesn't recognize these attributes. 我正在尝试使用django保存此python文件,但看来python无法识别这些属性。
Oh, and yeah, I installed django correctly. 哦,是的,我正确安装了django。 No issues.
没有问题。
the Django File class doesn't have a method "save" Here are the Django Docs for the File class: Django File类没有“保存”方法。这是File类的Django文档:
https://docs.djangoproject.com/en/dev/ref/files/file/ https://docs.djangoproject.com/en/dev/ref/files/file/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.