0

I set up django project on ubuntu 18.04 and apache2 but there is a problem. Media files don't save. When I try to upload file using django-filer I get 500 internal server error(I wrote simple plugin with charfield and filefield - the same happens) independently from DEBUG=True/False setting. I uploaded few files using manage.py runserver and this works great - I can even use these files in production but an attempt to upload any new one cause error settings.py:

MEDIA_URL = '/media/'
MEDIA_ROOT = '/mysite/public/media/'
STATIC_URL = '/static/'
STATIC_ROOT = '/mysite/public/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]

apache configuration:

alias /static /mysite/public/static
<Directory /mysite/public/static>
Require all granted
</Directory>

alias /media /mysite/public/media
<Directory /mysite/public/media>
Require all granted
</Directory>

<Directory /mysite/src/proj>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

WSGIDaemonProcess mysite python-home=/mysite/venv python-path=/mysite/src/
WSGIProcessGroup mysite
WSGIScriptAlias / /mysite/src/proj/wsgi.py

In conclusion: manage.py runserver works great. On production server I can manage files which were uploaded earlier but an attempt to upload a new one cause error 500.

1
  • If you used DEBUG=True in production can't you get the error from it? Feb 16, 2022 at 18:56

1 Answer 1

0

I think you need to change permissions of the media folder. Something like

sudo chmod -R 775 your_django_project/public/media
1
  • Thank you so much, I've browsed whole web and found nothing Feb 17, 2022 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.