Python Django 4.2.5 tutorial: introducing static files (css js img) into html

static files

illustrate

During the development process, generally:

  • picture
  • CSS
  • js

will be treated as static files.

static directory

1. 自定义appCreate a static folder in the directory. We create an img folder under static and put the 1.png image in it

Picture[4]-Django4.0 Tutorial-Ling Ning Blog

Then modify <app>/templates/index.htmlthe file

<!DOCTYPE html>

{% load static %}

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Title</title>

</head>

<body>



<h1>hello templates </h1>

<img src="{% static 'img\1.png' %}">

</body>

</html>

In this way png is introduced

Guess you like

Origin blog.csdn.net/a772304419/article/details/133563118