Django - referencing static files in templates

后端 未结 3 1244
深忆病人
深忆病人 2020-12-17 18:05

I\'m having difficulty referencing static files in my templates. I am using Twitter Bootstrap and have the bootstrap files (css, img, js) sitting at mysite/static.

3条回答
  •  情书的邮戳
    2020-12-17 18:45

    It should be

    {% load static %}
    

    And then something like

    
    
    
    

    Update for Completeness

    Folder Structure

    • proj
    • app1
    • app2
    • myproj_public
    • static
      • css
        • bootstrap.css
      • js
        • xyz.js

    Settings File

    STATIC_ROOT = os.path.join(os.path.abspath(
        os.path.join(PROJECT_ROOT, 'myproj_public', 'static')), '')
    
    STATIC_URL = '/static/'
    

提交回复
热议问题