当前位置:网站首页>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
边栏推荐
- Solve the compilation problem of "c2001: line breaks in constants"
- 2/11 matrix fast power +dp+ bisection
- Easyrecovery reliable and toll free data recovery computer software
- 图应用详解
- Query the number and size of records in each table in MySQL database
- [HBZ share] reasons for slow addition and deletion of ArrayList and fast query
- Lambda expression learning
- SharedPreferences 源码分析
- 电脑钉钉怎么调整声音
- [network] channel attention network and spatial attention network
猜你喜欢

Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)

Data processing methods - smote series and adasyn

捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统

ue5 小知识点 开启lumen的设置

Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code

Deep learning framework installation (tensorflow & pytorch & paddlepaddle)

Easyrecovery靠谱不收费的数据恢复电脑软件

How to estimate the population with samples? (mean, variance, standard deviation)

About some basic DP -- those things about coins (the basic introduction of DP)
![[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity](/img/ac/93a64e59592e3d083a771b993d6884.jpg)
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
随机推荐
Overturn your cognition? The nature of get and post requests
ue5 小知识点 开启lumen的设置
VPP性能测试
牛顿插值法
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
How does computer nail adjust sound
How to solve the problem of slow downloading from foreign NPM official servers—— Teach you two ways to switch to Taobao NPM image server
canal同步mysql数据变化到kafka(centos部署)
Dry goods collection | Vulkan game engine video tutorial
Stable Huawei micro certification, stable Huawei cloud database service practice
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
Stable Huawei micro certification, stable Huawei cloud database service practice
P2102 floor tile laying (DFS & greed)
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
Tengine kernel parameters
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
Complete list of common functions of turtle module
2327. 知道秘密的人数(递推)