Thanks a lot for the detailed article @mjhea0.
I was able to follow it from start to end and the only part that didn't work for me was STATIC_ROOT = BASE_DIR / "staticfiles"
, where I'm getting TypeError: unsupported operand type(s) for /: 'str' and 'str'
, but replacing it with STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
made it work without major inconvenience.
Other than that, here's my main question: how can I make the media dir accessible from the host?
I tried in the same fashion as I was doing with my database (making sure the directory was created beforehand), but no luck.
Here's the relevant change: lynx-chess/OpenBench@cc99ad4
And here the sad result of the attempt.
![image](https://private-user-images.githubusercontent.com/11148519/258672098-fec80d0d-14a7-4f6a-8a08-a39f7c0d04fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE1OTUyNTAsIm5iZiI6MTcyMTU5NDk1MCwicGF0aCI6Ii8xMTE0ODUxOS8yNTg2NzIwOTgtZmVjODBkMGQtMTRhNy00ZjZhLThhMDgtYTM5ZjdjMGQwNGZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIxVDIwNDkxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUyZWMwN2JmZjFhMDA5ZDA4MmYxODRmMGQwN2EyMjk1MmVjNjEwNmRmMTBjNTUyNmQwZjI0M2Y2MGZmZTYyYWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jr8W7jvxk_P5ZZtxm5P3Ni_I5DYUaxEF7W2xI8uBfTw)
Environment:
Request Method: POST
Request URL: http://localhost/
Django Version: 4.2.1
Python Version: 3.11.4
Installed Applications:
['OpenBench',
'OpenBench.templatetags',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'upload']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'htmlmin.middleware.MarkRequestMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/web/upload/views.py", line 9, in image_upload
filename = fs.save(image_file.name, image_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/files/storage/base.py", line 38, in save
name = self._save(name, content)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/files/storage/filesystem.py", line 106, in _save
fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: PermissionError at /
Exception Value: [Errno 13] Permission denied: '/home/app/web/media/quota.PNG'