Python Newbie
Python Newbie

Reputation: 381

{% load static %} what does this snippet achieve?

Dears, I was learning the Django official tutorial. In the entire process, I did not create a custom tag set called "static". What does load static achieve here?

According to Django docs, load plays this following role.

load

Loads a custom template tag set.

For example, the following template would load all the tags and filters registered in somelibrary and otherlibrary located in package package:

Upvotes: 2

Views: 92

Answers (1)

Alireza Atashnejad
Alireza Atashnejad

Reputation: 631

when you wont to add CSS, javascript, HTML or etc to our python project, you need to make a folder on root direction and called assets.

after this, in setting.py you need to add some words to Django knows where you store your files(CSS,js, HTML)

and finally, you must add this tag {% load static % } in your HTML files, to when you load HTML files, static files load with this.

I create a simple Django project, to show you how you could use them.

this project on my GitHub right now called: Django/ First app

please check this link : Github - First App - Templates

if is helpful, please take a vote. thanx

Upvotes: 1

Related Questions