Home > Mobile >  Django: "[Errno 13] Permission denied: '/samples'" during file upload via model
Django: "[Errno 13] Permission denied: '/samples'" during file upload via model

Time:09-29

I'm trying to push a sample file from admin page, via a model. Whole website works fine but I'm just getting this problem with this specific model.

Model

class File(models.Model):
    area = models.OneToOneField(Actions, on_delete=CASCADE)
    sample_file = models.FileField(
        upload_to='samples/', validators=[validate_file_extension])

Info

samples/ Directory relies in BASE_DIR of project.

Tried Fixes

Read few articles, and got few ideas about permissions but my permissions are correct as well, folder is under www-data

drwxr-xr-x 2 www-data www-data 4096 Sep 24 17:53 samples

I even tired changing permissions to 777 but didn't worked.

Am I missing something here.

CodePudding user response:

Permissions are perfect,if you get any issue like this then, any directory you must have to add in setting.py

and for permissions use chown -R www-data /var/www/

  • Related