I am having an issue using Django Admin to upload an image to my production site.
I am running Apache HTTPD server with sqlite db.
Uploading works fine when running the development server, but when I attempt to add add a new entry to my site that includes an image I am greeted with the error:
PermissionError at /admin/homepage/jumbotron/add/
I've attempted to research this error to the best of my ability but I am at a lost now.
I have checked the file permissions including setting the group and owner to http http which is the user that apache httpd server is running under.
I went ahead and temporarily gave my static folder full permissions with chmod -R 777 and restarted the httpd server, but the error still remained. I did a full system restart as well.
The current file permissions are now:
drwxrwxr-x 8 http http 4096 Jul 3 16:48 static
I have tried other methods inside my setting.py like changing STATIC_URL to the full path or removing the first slash, so it's static/ and then restarting the server and nothing; no dice.
setting.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates'), ]
SECURE_SSL_REDIRECT = True
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'homepage',
'blog',
'portfolio',
]
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',
]
ROOT_URLCONF = 'blogsite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': TEMPLATE_DIRS,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'homepage.context_processors.add_navbar_data_to_base'
],
},
},
]
STATIC_URL = 'static/'
I did some tweaks to the httpd.conf file and landed on these settings after trying Require all granted under the /static folder
httpd.conf
<VirtualHost *:443>
Alias /static /srv/http/blogsite/static
<Directory /srv/http/blogsite/static>
Order allow,deny
Allow from all
</Directory>
<Directory /srv/http/blogsite/blogsite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess blogsite python-path=/srv/http/blogsite python-home=/srv/http/django
WSGIProcessGroup blogsite
WSGIScriptAlias / /srv/http/blogsite/blogsite/wsgi.py
</VirtualHost>
models.py
class Jumbotron(models.Model):
title = models.TextField(default="")
description = models.TextField()
display_order = models.IntegerField()
slideimage = models.FileField(upload_to="static/homepage")