Reputation: 5654
I'm trying to deploy my Django(1.10) project on Ubuntu 18.04 with Apache2 using Mode_WSGI
I have set up my project folder inside home
as Fetchors
directory and add permissions to it as:
total 40
drwxr-xr-x 6 abdul abdul 4096 Feb 10 15:48 .
drwxr-xr-x 5 root root 4096 Feb 11 04:40 ..
-rw------- 1 abdul abdul 3930 Feb 11 02:14 .bash_history
-rw-r--r-- 1 abdul abdul 220 Apr 4 2018 .bash_logout
-rw-r--r-- 1 abdul abdul 3771 Apr 4 2018 .bashrc
drwx------ 3 abdul abdul 4096 Feb 10 15:37 .cache
drwx------ 3 abdul abdul 4096 Feb 10 15:34 .gnupg
-rw-r--r-- 1 abdul abdul 807 Apr 4 2018 .profile
drwx------ 2 abdul abdul 4096 Feb 10 15:34 .ssh
drwxrwxr-x 9 abdul www-data 4096 Feb 11 06:27 Fetchors
And here are the permissions inside media
directory:
total 16
drwxrwxr-x 4 abdul www-data 4096 Feb 10 15:37 .
drwxrwxr-x 9 abdul www-data 4096 Feb 11 06:27 ..
drwxrwxr-x 2 abdul www-data 4096 Feb 10 15:37 driver_image
drwxrwxr-x 2 abdul www-data 4096 Feb 10 15:46 product_image
I'm creating a proudct object which need to save the product image inside product_image
folder but it says:
[Errno 13] Permission denied: 'media/product_image'
How can I fix this issue?
Thanks in advance!
Upvotes: 1
Views: 491
Reputation: 5654
I have solved this issue by changing my MEDIA_ROOT
path in settings.py
as:
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
Then, it will grab the appropriate permissions of the Project.
Upvotes: 0
Reputation: 511
Give permission to your media folder by running this command in the terminal
sudo chmod -R 777 media
but this is a bad solution follow the advice on this answer https://stackoverflow.com/a/21797786/5301788
Upvotes: 2