settings.py file
STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ]
If there is some static files and are not linked to any app. That is no longer any directory of a app. You can add STATICFILES_DIRS in settings.py, the DTL will look after the static file path in this list. For example, we create a new static in the same directory manage.py folder. Then in settings.py: Add STATICFILES_DIRS in
html file
{% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CBlist</title> <link rel="stylesheet" href="{% static 'plugins/bootstrap/css/bootstrap.css' %} "/> <link rel="stylesheet" href="{% static 'plugins/font-awesome/css/font-awesome.css' %} "/> <link rel="stylesheet" href="{% static 'css/commons.css' %} "/> <link rel="stylesheet" href="{% static 'css/nav.css' %} "/> </head> <body> <h1>你好</h1> </body> </html>
Note: {% load static%} needs to be placed html head position (at least using the above static tag), usually on the top of html. If {% extend%} tags and {% load static%} exist, {% extend%} needs to be placed on top, then add {% load static%} and other labels.