Home Web Front-end JS Tutorial How Django loads css and js files and static images

How Django loads css and js files and static images

Apr 21, 2018 am 10:56 AM
django javascript load

This article introduces how Django loads css and js files and static images. It has certain reference value. Now I share it with you. Friends in need can refer to it

1. First, we should create a folder named static. This folder is used to save and store css, js and image files. We can create file css, images, and js folders in static to store three files. Class files and folder names are not fixed. They are chosen this way to facilitate memory.


2. After creating the folder, write the code in settings

STATICFILES_DIRS=(
os.path.join(BASE_DIR,'static'),
)
Copy after login


3. Then load static in the head of the page using the style


##

{% load static %}
Copy after login
After the above configuration is completed, you can Loaded

For example, loading css file

Loading image file



Related recommendations:

Dynamic loading of CSS and JS files using JavaScript

For the loading and execution process of CSS, JS, and HTML in HTML pages

html delayed loading of JS and CSS

jquery dynamically loads css, js files

The above is the detailed content of How Django loads css and js files and static images. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Error loading plugin in Illustrator [Fixed] Error loading plugin in Illustrator [Fixed] Feb 19, 2024 pm 12:00 PM

Error loading plugin in Illustrator [Fixed]

Stremio subtitles not working; error loading subtitles Stremio subtitles not working; error loading subtitles Feb 24, 2024 am 09:50 AM

Stremio subtitles not working; error loading subtitles

Django vs. Flask: A comparative analysis of Python web frameworks Django vs. Flask: A comparative analysis of Python web frameworks Jan 19, 2024 am 08:36 AM

Django vs. Flask: A comparative analysis of Python web frameworks

Django Framework Pros and Cons: Everything You Need to Know Django Framework Pros and Cons: Everything You Need to Know Jan 19, 2024 am 09:09 AM

Django Framework Pros and Cons: Everything You Need to Know

How to upgrade Django version: steps and considerations How to upgrade Django version: steps and considerations Jan 19, 2024 am 10:16 AM

How to upgrade Django version: steps and considerations

Outlook freezes when inserting hyperlink Outlook freezes when inserting hyperlink Feb 19, 2024 pm 03:00 PM

Outlook freezes when inserting hyperlink

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

Simple JavaScript Tutorial: How to Get HTTP Status Code

Is Django front-end or back-end? check it out! Is Django front-end or back-end? check it out! Jan 19, 2024 am 08:37 AM

Is Django front-end or back-end? check it out!

See all articles