Django URL path vs. style relative path in template

Source: Internet
Author: User

Static directory has CSS and JS and image folders, which put some static files of the site, static in the site root directory, Configuring static files in Django This is a matter of the Internet, and yesterday, when adding new content, found a problem, My URL If there are multiple "/" words (my is more than 3 such as:/A/B/C/D), the template calls to the static file will not be able to get references to static files in templates:

<link rel= "stylesheet" type= "Text/css" href= ". /.. /static/easyui/easyui.css ">

in this way, the path of the calling static file becomes/a/static/easyui/easyui.css, causing the static files to be loaded incorrectly, I later wondered if it was possible to configure a new URL path at the time of the Django URL match, but it didn't seem to work. after a lot of other methods, but not all, and finally no way, can only take the most brutal solution, change the template's call to

<link rel= "stylesheet" type= "Text/css" href= ". /.. /.. /static/easyui/easyui.css ">

In this case the /A/B/C/D can be correctly displayed, but for the/a/b this path will have an impact? Because this is the same template implementation, it is not possible to write two identical templates for this reason, so try the following/a/b this path for

<rel= "stylesheet"  type= "text/css"  href= ". /.. /.. /static/easyui/easyui.css ">

This is also the right to display, Since this can also be displayed correctly, then I add a few more. /What,

<link rel= "stylesheet" type= "Text/css" href= ". /.. /.. /.. /.. /.. /.. /.. /.. /static/easyui/easyui.css ">

The result is that there is no problem. when matching to the corresponding file, the extra: /will be ignored. write This down in case you forget the same question later.

Django URL path vs. style relative path in template

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.