Introduce ColorField for consistent represention of color choice fields in forms

This commit is contained in:
jeremystretch
2021-06-09 17:17:39 -04:00
parent ae5f1b5a4f
commit 1fd53531d6
3 changed files with 34 additions and 50 deletions

View File

@@ -20,6 +20,7 @@ from .constants import *
from .utils import expand_alphanumeric_pattern, expand_ipaddress_pattern
__all__ = (
'ColorField',
'CommentField',
'ContentTypeChoiceField',
'ContentTypeMultipleChoiceField',
@@ -69,6 +70,13 @@ class SlugField(forms.SlugField):
self.widget.attrs['slug-source'] = slug_source
class ColorField(forms.CharField):
"""
A field which represents a color in hexadecimal RRGGBB format.
"""
widget = widgets.ColorSelect
class TagFilterField(forms.MultipleChoiceField):
"""
A filter field for the tags of a model. Only the tags used by a model are displayed.