简体   繁体   中英

Static files not loading with Django. (Bootstrap not working)

I have read many posts about the topic and tried to follow all the suggestions (new to python here) but I am unable to get bootstrap to work in Django.

I have a project "myoffice" and an app "proposals" in it.

I have downloaded a css file and put it in following folder

django\\bin\\myoffice\\proposals\\static\\bootstrap\\bootstrap.min.css

I have made following changes to the settings.py

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATICFILES_DIRS = (

os.path.join(
        os.path.dirname(__file__),
        'static',
)

STATIC_URL = 'proposals/static/'

and included static files in my template like this.

<!DOCTYPE html>

<html>
<head>
    {% load staticfiles %}
    <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
</head>
<body>

But it is still showing view without any formatting.

I figured it out. It was actually a stupid error. I discovered, I have to restart the webserver after adding css file to the static directory and making changes to the settings.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM