search

Home  >  Q&A  >  body text

python - Django自定义模板标签和过滤器

通过官方手册来自定义了过滤器,自定义过滤器可以使用,但是发现自带的static 无法使用,js,css等没办法加载

阿神阿神2825 days ago721

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-18 09:34:41

    static is a separate problem
    Take http://192.168.0.27:8000/stat... as an example
    Project path (the folder where manage.py is located): c:/test/
    app path: c: /test/app/

    1. Add: STATIC_URL = '/static/' in the setting
    That is, directly call the static file in the app path, such as: c:/test/app/static/bootstrap.min.css

    2. Add: STATIC_ROOT = os.path.join(BASE_DIR,'static')
    You need to execute python manage.py collectstatic
    under the c:/test/ path and then call c:/test/static/ The file bootstrap.min.css

    reply
    0
  • Cancelreply