[英]Django - Apache Server Error (500) when uploading/saving file
I am attempting to deploy a Django site that has the ability to upload a file and then modify that file. 我正在尝试部署一个能够上传文件然后修改该文件的Django站点。 It works 100% on the dev server, however after deploying it with Apache I am running into problems.
它在开发服务器上可以100%工作,但是在用Apache部署它之后,我遇到了问题。 The Server Error (500) happens on the indicated line in my views.py.
服务器错误(500)发生在我的views.py中的指示行上。 What am I doing wrong?
我究竟做错了什么? My problem is probably not understanding the save() method, however I could not find any info/documentation that helped me.
我的问题可能是不了解save()方法,但是找不到任何对我有帮助的信息/文档。
views.py views.py
def upload(request):
if request.method == "POST":
formU = FileUploadForm(request.POST, request.FILES)
if formU.is_valid():
f = request.FILES['myFile']
fs = FileSystemStorage()
set_file_name(str(f))
fs.save(str(f), f) # where error occurs
Since everything works fine under the dev server, I assumed it would be a media file thing but (I think) all looks good there. 由于在开发服务器下一切正常,我以为这是媒体文件,但是(我认为)在那里一切都很好。
settings.py settings.py
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
MEDIA_URL = '/media/'
proj.conf proj.conf
Alias /media /home/4rsenal/f_proj/media
<Directory /home/4rsenal/f_proj/media>
Require all granted
</Directory>
If it was working on the dev server, it's probably not a Python error. 如果在开发服务器上运行,则可能不是Python错误。 I think you have a bad configuration of your virtualhost in proj.conf.
我认为您在proj.conf中虚拟主机的配置错误。 Or you just forget to open rights on your folders ?
还是忘记了打开文件夹的权限?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.