通过URL访问django中的静态资源
2019-03-10 本文已影响0人
明灭_
- 将资源放在static目录下
(此处假设资源路径为static/imgs/test.png) - 在settings.py中添加如下代码:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
- 访问如下连接
http://localhost:8000/static/imgs/test.png
即可获取test.png
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
http://localhost:8000/static/imgs/test.png
即可获取test.png