Eu finalmente encontrei uma maneira de corrigir isso. Eu removi o .. de STATIC_ROOT
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = '/static/'
Eu criei um ambiente básico do Python Django na AWS. Meu projeto é gerado com django-admin startproject michaelmalura
. Eu adicionei um aplicativo com django-admin startapp blog
.
Depois de publicar meu projeto com eb deploy
, tudo no frontend funciona bem. Mas o backend não mostra nenhum estilo.
settings.py
...
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog'
]
...
STATIC_ROOT = os.path.join(BASE_DIR, "..", "static")
STATIC_URL = '/static/'
django.config
container_commands:
01_migrate:
command: "python manage.py migrate --noinput"
leader_only: true
02_collectstatic:
command: "python manage.py collectstatic --noinput"
option_settings:
"aws:elasticbeanstalk:container:python:environment":
DJANGO_SETTINGS_MODULE: "michaelmalura.settings"
aws:elasticbeanstalk:container:python:
WSGIPath: "michaelmalura/wsgi.py"
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
Erro de administrador
Failed to load resource: the server responded with a status of 404 (Not Found)
http://michaelmalura.eu-central-1.elasticbeanstalk.com/static/admin/css/base.css
Eu finalmente encontrei uma maneira de corrigir isso. Eu removi o .. de STATIC_ROOT
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = '/static/'