Access to user home directory from django

I am creating a Django application that can access the user's home directory. For this, I want to create a directory using something like os.mkdir('/home/user/new_directory')or subprocess commands.

Since Django is started by the apache server, python acts as an apache user and cannot access my users' home directories.

Currently, I know the login of my users because they must be registered on the website. Is there a solution to execute unix commands from Django / Python in the username ?

+4
source share
1 answer

You can set home directories via MEDIA_URL/ or a symbolic link. I am thinking of combining calls to symlink and os.system calls.

what-is-symlinking-and-how-can-learn-i-how-to-to-do-this

To change apache user use os.system(su <command>) changing-user-in-python

0
source

Source: https://habr.com/ru/post/1648778/


All Articles