当前位置:网站首页>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
边栏推荐
- P3500 [poi2010]tes intelligence test (two points & offline)
- [HBZ sharing] how to locate slow queries in cloud database
- 牛顿插值法
- Tengine kernel parameters
- Ue5 small knowledge freezerendering view rendered objects in the cone
- Visio draws Tai Chi
- Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
- HotSpot VM
- [Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
- Basic explanation of turtle module - draw curve
猜你喜欢
How to estimate the population with samples? (mean, variance, standard deviation)
查询mysql数据库中各表记录数大小
The value of two date types is subtracted and converted to seconds
Deep learning framework installation (tensorflow & pytorch & paddlepaddle)
ETCD数据库源码分析——etcdserver bootstrap初始化存储
How many of the 10 most common examples of istio traffic management do you know?
Selection of slow motion function
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
View 工作流程
Easyrecovery reliable and toll free data recovery computer software
随机推荐
Dry goods collection | Vulkan game engine video tutorial
Visio draws Tai Chi
Complete list of common functions of turtle module
Solutions: word coverage restoration, longest serial number, Xiaoyu buys stationery, Xiaoyu's electricity bill
Hashlimit rate control
npm命令--安装依赖包--用法/详解
Figure application details
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
Lombok principle and the pit of ⽤ @data and @builder at the same time
Yyds dry goods inventory OSI & tcp/ip
How does vs change the project type?
Sentinel sliding window traffic statistics
Mixed development of QML and QWidget (preliminary exploration)
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
[HBZ sharing] how to locate slow queries in cloud database
729. 我的日程安排表 I(set or 动态开点线段树)
CADD course learning (8) -- virtual screening of Compound Library
Mysql database storage engine
E. Best Pair
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)