1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

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 b3ed545d6a
commit a1ba3b567c
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.