[Fixed]-Django admin site not showing CSS style

27👍

Your Apache configuration requires that all static content (CSS, JS, images etc) should be in the mysite/static directory. You should collect your static content from apps into the mysite/static directory first:

cd /home/ubuntu/cs462/mysite
python manage.py collectstatic

Update: If you did not specify a location for static content, you should add the following lines to your settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
👤Selcuk

1👍

Keep DEBUG=False

Run

pip install whitenoise

IN settings.py

add INSTALLED_APPS

'whitenoise.runserver_nostatic',

Add like below in MIDDLEWARE:

'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',  # add it exactly here
'django.contrib.sessions.middleware.SessionMiddleware',

Don’t Change below statements:

STATIC_URL = ‘/static/’

STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)

0👍

after doing

  1. python manage.py collectstatic
  2. In settings.py, in STATICFILES_DIRS variable, append

(‘admin’, os.path.join(BASE_DIR, ‘static’, ‘admin’)). This should work

👤nish

Leave a comment