The static files always give me a 404 error and I can't see why,I copied a style I've used before but not with this version of django.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATIC_DIR = [
os.path.join(BASE_DIR,"static")
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static'
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',
]
I was using cdn and style tag for the whole time working on the project but now i want to wrap it up and use some css/js files already ready for me.
I tried collecting the static files by python manage.py collectstatic
and it collected all the static files in the static folder but still doesn't load them and returns a 404 error
my dir:
/Eyelizer
/App1
/App2
/Eyelizer
/static
/css
/main1.css
/Eyelizer
/css
/wanted.css
/js
/wanted.js
/images
/templates
/media
Every kind of help is appreciated and thank you.
I don't think there is anything like STATIC_DIR
but it is STATICFILES_DIRS
.
And also you have made a typo mistake in STATIC_ROOT
while closing the bracket.
Just put the below in settings.py
by removing all static related things.
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'