Passing color to html, css
Closed this issue · 1 comments
ksvoboda commented
Hello everyone,
I am kinda new to this, and I am creating a small website and I need this.
I wonder if I set color in Django admin, how can I transfer that color to HTML (background color in div, etc)
Thanks
pix666 commented
Suppose you have the following model:
# models.py
class Article(models.Model):
header_color = ColorField(_('color'), default='#000000')
header = models.CharField(_('header'), max_length=255)
You could then do the following:
{# detail.html #}
<h1 style="color: {{ object.header_color }}">{{ object.header }}</h1>