Python/django logging permissions error

Viewed 2219

When running a command using the manage.py script, django gives me a permission denied error:

vagrant@vagrant:/opt/proj$ python3 manage.py migrate

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/config.py", line 558, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/lib/python3.5/logging/config.py", line 731, in configure_handler
    result = factory(**kwargs)
  File "/usr/lib/python3.5/logging/__init__.py", line 1008, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.5/logging/__init__.py", line 1037, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/var/log/django/debug.log'

But I am in the correct group (as far as I can see), and I can touch the logfile using the shell:

vagrant@vagrant:/var/log/django$ ls -la
total 20
drwxrwxr-x  2 nobody www-data  4096 Jul 20 13:06 .
drwxrwxr-x 12 root   syslog    4096 Jul 20 12:37 ..
-rwxrwxr-x  1 nobody www-data 11283 Jul 20 13:07 debug.log

vagrant@vagrant:/var/log/django$ groups
vagrant adm cdrom sudo dip www-data plugdev lxd lpadmin sambashare

vagrant@vagrant:/var/log/django$ touch debug.log

vagrant@vagrant:/var/log/django$

Can anyone help me understand what the issue is here ? I'm using the vagrant 'bento' ubuntu 16.04 image.

Edit: Just to be clear, it does work fine if I set the permissions to 777 on the log file. But I'd rather keep them as 775 (or less).

2 Answers
Related