at-rule or selector expected in django html

57 Views Asked by At

I have a model in django and I want to call the model's value fields in my style tag for a CSS property but I face this error Actually I want to set background-color from backend how can I fix it? enter image description here

1

There are 1 best solutions below

0
On

This is not an error, this is just Visual Studio that does not understand that the template is being rendered.

Indeed, the template inspector expects something like:

body {
  background-color: #ff0000;
}

now given that the settings.website_background_color exists, and is valid, it will render that, but the Visual Studio inspector does not know you will render the template.

There might however be a problem that Django will ampersand-escape content. You can avoid that with the |safe template filter [Django-doc], but this will not remove the warning:

body {
  background-color: {{ settings.website_background_color|safe }};
}