The Django template references static resources (JS,CSS, etc.)

Source: Internet
Author: User

Django template is unavoidable to use some JS and CSS files, check a lot of pages, was made slightly dizzy, or the official website, to a link you can see their own English.

The general steps are this:

1. Make sure that the Installed_apps in the include Django.contrib.staticfiles, and no one can add it.

2. Also add in, we need to add static resource related configuration. It can be written like this:

Staticfiles_dirs= (
Os.path.join (Base_dir, ' ... /.. /static '). replace (' \ \ ', '/'),

3. This is not enough, put your static directory in your app directory, so Django will automatically find the static directory under each application.

4. This is okay in the template.

Add {% load staticfiles%} to the template

When used as shown:

This way, you can make your template style more beautiful.

The Django template references static resources (JS,CSS, etc.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.