{{STATIC_URL}} with a django jacket

I have some problems adding my CSS to my template using {{STATIC_URL}}. The tag does not work inside link markup, but it works elsewhere. It:

{{ STATIC_URL }} 

correctly translated into

 /static/ 

but

 link(href="{{ STATIC_URL }}css/bla.css" 

to become

 <link href="{{ STATIC_URL }}css/bla.css"> 

I am using pajade with Django. Can anyone help with this?


edit I found the answer: if you want to use static attributes, use '! = 'instead of' = '. Example:

 link(href!="{{ STATIC_URL }}css/bla.css" 
+4
source share
2 answers

Finally, I found the answer from here: https://github.com/SyrusAkbary/pyjade/issues/44

use href = STATIC_URL + 'css / bla.css' link or href = '# {STATIC_URL} css / bla.css' link

In addition to this situation, I met some problems when I use jade to write for a loop in a template. I used the django template instead of jade for loop.

+1
source

You must use the correct static tag.

 {% static "file_to_include" %} 

and load the static lib into your template.

BTW: Since there are no updates, and his successor was recently removed from pypi, I took the liberty of reviving it: https://github.com/kakulukia/pypugjs

Version 5.0.1 fixed incompatibilities with the latest versions of Django.

0
source

Source: https://habr.com/ru/post/1441535/


All Articles