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')
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
- python manage.py collectstatic
- In settings.py, in STATICFILES_DIRS variable, append
(‘admin’, os.path.join(BASE_DIR, ‘static’, ‘admin’)). This should work
👤nish
- Django: Highlight current page in navbar
- How to create or register User using django-tastypie API programmatically?
- Getting error cannot import name 'six' from 'django.utils' when using Django 3.0.0 latest version
- Django signals for new entry only
Source:stackexchange.com