4rsenal 4rsenal - 1 year ago 109
Apache Configuration Question

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. It works 100% on the dev server, however after deploying it with Apache I am running into problems. The Server Error (500) happens on the indicated line in my 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.

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

MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
MEDIA_URL = '/media/'


proj.conf

Alias /media /home/4rsenal/f_proj/media
<Directory /home/4rsenal/f_proj/media>
Require all granted
</Directory>

Answer Source

If it was working on the dev server, it's probably not a Python error. I think you have a bad configuration of your virtualhost in proj.conf. Or you just forget to open rights on your folders ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download