models.pyにて、色の指定を16進数のカラーコードで受け入れる。その16進数カラーコードを、色名(orangeとかforestgreenとか)に書き換える。 そういうカスタムテンプレートフィルタを自作する方法を解説する。 models.pyのカラーコード受け入れ from django.db import models from django.core.validators import RegexValidator """ 省略 """ color_regex = RegexValidator(regex=r'^#(?:[0-9a-fA-F]{3}){1,2}$') color = models.CharField(verbose_name="リボン色",max_ ...