Configured a web server for a Django application using nginx , uwsgi . Everything works fine, but when adding files through the admin panel Django gives an error:

[Errno 13] Permission denied : path to the media files directory (where Django should save the file) Exception Location: /home/django/venv/lib/python3.4/site-
packages / django / core / files / storage.py in _save, line 264 Python Executable: / home / django / venv / bin / uwsgi Python Version: 3.4.3 Python Path: ['.', '', / / ​​home / django / venv / lib / python3.4 ',
'/home/django/venv/lib/python3.4/plat-x86_64-linux-gnu',
'/home/django/venv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/django/venv/lib/python3.4/site-packages']

At the same time through the admin panel, you can add new data to the model if there is no media. I would appreciate any advice.

  • Obviously, the user under which uwsgi works does not have permission to write to MEDIA_ROOT . - Sergey Gornostaev
  • and how to check under what user uwsgi works? - Sultan Nasirov
  • The user who is running uwsgi in the file uwsgi.ini - uid - AlTheOne
  • In general, I tried differently, nothing comes out - Sultan Nasirov
  • added the user from whom it was started in www-data, added www-data privileges. Desperate to do chmod 0777 homome. The result is the same - Sultan Nasirov

1 answer 1

Solution: add a user through which the uwsgi.ini file is launched to the group with access to the necessary directories.

  usermod -a -G django www-data -a add( добавить) -G group(группа) django - username www-data - group name 

In some places they write that the name of the group should stand first, but it was this option that worked for me.