Search code examples
djangosass

SASS/SCSS django


PHOTO - show mistake(https://i.sstatic.net/wXCf5.png)

Why got red underline (photo) as some problem in code, is there are some mistake? But it work properly... And the same question to sass in link...

What to do for remove this "mistake".

{% load sass_tags %}

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="{% sass_src 'css/main.scss' %}" rel="stylesheet" type="text/css"/>
        <title>Django Sass</title>
    </head>
    <body>
        <h1>WORK</h1>
    </body>
<html>


Solution

  • Why got red underline (photo) as some problem in code, is there are some mistake?

    No, for the first photo there is a mistake: you can not use the {% sass_src … %} template tag if you don't load it into the scope. So you should add {% load sass_tags %}, like you did.

    Now the HTML inspector however thinks it found a problem: the first line in the rendered HTML code should be the first tag, but since {% load sass_tags %} will not generate any content, that will be the case.

    For some (very) old browsers, there can be problems for the first line being empty and then a line with <!DOCTYPE html>, so it might be advisable to use:

    {% load sass_tags %}<!DOCTYPE html>
    

    so on the same line, but likely the HTML inspector will still not be happy, but it is not a problem: this is simply the inspector not understanding the {% load … %} Django template tag, which is resolved at server side.