当前位置:网站首页>8. Static file
8. Static file
2022-07-06 04:33:00 【Suyuoa】
Like a picture ,css,js, Audio , Video these are static files
Catalog
1 Configuration of static files
3 Use static files in templates
1 Configuration of static files
The configuration of static files is in setting.py Here
This is the default value after the project is created , It can be changed, but it is not necessary
Then we will join STATICFILES_DIRS This variable , This is the storage path for static files , We write like this
- There can be multiple , Here we only use one
Then we create a folder under the project path static, For storing static files
stay static Under the directory, we can create different folders according to different types of static files , such as
2 Accessing static files
Now let's make a map static/picture in
Then we can visit it directly in the browser
Find that you can access , Let's use this image through views and templates
3 Use static files in templates
We use img label
First, make a template , We call it static_picute, Then we write
The above is the absolute path , The following is the relative path , Static files can be called multiple times in the template
Then add the view
Finally, add routing
Then we visit
The above two are html Writing , Now let me say something django Special writing in ——static label , We write this in the template
- There is a prompt red line, but it does not delay the use
Let's visit
Generally speaking, we use static label , In this way, when we need to change later, we need to change less
边栏推荐
- 2328. Number of incremental paths in the grid graph (memory search)
- P2102 地砖铺设(dfs&贪心)
- Comprehensive ability evaluation system
- 729. My schedule I (set or dynamic open point segment tree)
- NPM command -- install dependent packages -- Usage / explanation
- Solve the compilation problem of "c2001: line breaks in constants"
- ETCD数据库源码分析——etcdserver bootstrap初始化存储
- Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
- hashlimit速率控制
- VNCTF2022 WriteUp
猜你喜欢
Selection of slow motion function
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
[tomato assistant installation]
颠覆你的认知?get和post请求的本质
About some basic DP -- those things about coins (the basic introduction of DP)
Comprehensive ability evaluation system
Basic use of MySQL (it is recommended to read and recite the content)
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Stable Huawei micro certification, stable Huawei cloud database service practice
随机推荐
npm命令--安装依赖包--用法/详解
关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
[leetcode question brushing day 33] 1189 The maximum number of "balloons", 201. The number range is bitwise AND
The value of two date types is subtracted and converted to seconds
CADD course learning (8) -- virtual screening of Compound Library
图应用详解
Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
Ue5 small knowledge freezerendering view rendered objects in the cone
解决“C2001:常量中有换行符“编译问题
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
食品行业仓储条码管理系统解决方案
word封面下划线
Lombok原理和同时使⽤@Data和@Builder 的坑
P2022 有趣的数(二分&数位dp)
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
Lora gateway Ethernet transmission
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
CertBot 更新证书失败解决
In depth MySQL transactions, stored procedures and triggers