Django - referencing static files in templates

后端 未结 3 1242
深忆病人
深忆病人 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:40

    When you set static_root, for example:

    STATIC_ROOT = os.path.join(BASE_DIR, "static_root/")
    

    , all files are copied there, instead of in project_root/static. It is a new mechanism introduced in Django 1.3, to easy the static file processing: it will collect all files in each STATICFILES_DIR and all static dir under each installed app, so you copy them once in all.

    Refer the css/js files with static_root path.

提交回复
热议问题