I am trying to change the CSS of a page based on the model PageSettingI'm using. I allow the user to change the theme style based on some attributes PageSetting.
class PageSettings(SingletonModel):
theme = models.IntegerField(choices=THEMES,
verbose_name=_("Theme"),
default=0)
base_color = RGBColorField(blank=False,
verbose_name=_("Base color"),
default="bc0000")
...
What I would like to do is change some values in my css depending on base_color. Pretty much something like this:
.side-bar {
background: {{ pagesetting.base_color }};
float:left;
width: {{ pagesetting.sidebar_width}}%
...
}
is this in django? I know what I can do
<div class="sidebar" style='background-color:#{{pagesetting.base_color}};'>
but it makes my html ugly and harder to debug.
source
share