Skip to content Skip to sidebar Skip to footer

Accessing Static In Django

I'm having trouble sorting my static directory and linking css files through templates in html pages with django. I keep getting the error 'Not Found: /CSS/bootstrap.min.css' I kn

Solution 1:

You are almost there! You just need to add the correct static file directory to your STATICFILES_DIRS.

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# STATIC_URL tells django the url path to use for all static files. It 
# doesn't really have anything to do with your file locations on your 
# computer.
STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
    # Add this line here.
    os.path.join(BASE_DIR, "capstonenotespool", "static"),
]

Solution 2:

I think You must check again your static url, I think you config be wrong.

Here is answer you looking for.

Example of tree file

And this is my config for this

STATIC_URL = '/static/'

if DEBUG:

MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", >"static-only")

MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", >"media")

STATICFILES_DIRS = ( os.path.join(os.path.dirname(BASE_DIR), "static", "static"),

)


Post a Comment for "Accessing Static In Django"