Django static file search logic

Source: Internet
Author: User

Recently, Django's static file configuration went crazy. let's look at the underlying code: Use manage finstatic XXXX first. JS looks at the processing logic and finds that it mainly involves: C: \ python27 \ Lib \ Site-packages \ Django \ contrib \ staticfiles \ finders. find function in Py, as follows:

Debug the find method of the filesystemfinder class in C: \ python27 \ Lib \ Site-packages \ Django \ contrib \ staticfiles \ finders. py:

Shit happens, because locations is empty, cannot be found. How does it assign values? As follows:

Conclusion: you need. define staticfiles_dirs in Py, so that Django will know where to find it. instead of defining static_root, If you think so, you are as wishful thinking as I do. this variable is used for manage collectstatic. what a shit.

This is the search logic of the project.

What about apps? By default, search for the folder defined by static_url in the app. So, you see? The search logic in the app is as follows (first, then below ):

 

Django static file search logic

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: info-contact@alibabacloud.com 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.