Django - Template CSS call

Django Version: 2.1




A: configuration file settings.py

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            
STATIC_URL="/static_xxx/"
            
STATICFILES_DIRS=(
    os.path.join(BASE_DIR,"static"),
)

II: template calls (both methods must be configured settings.py file)

        1. Template Language
            1> Statement {% load staticfiles%} in <head> tag
            2> Link CSS

 <link rel="stylesheet" type="text/css" href="{% static_xxx "abc.css" %}">


        2. Use a virtual path
            1> do not declare the Load staticfiles%%} {
            2> Links CSS

 <link rel="stylesheet" type="text/css" href="/static_xxx/abc.css">

 

 

Guess you like

Origin blog.csdn.net/qq_42292831/article/details/93869926