Misc cleanup

This commit is contained in:
Jeremy Stretch
2018-07-30 14:00:37 -04:00
parent f664998d9b
commit f7aa259995
7 changed files with 36 additions and 12 deletions

View File

@@ -5,7 +5,12 @@ from django.db import models
from .forms import ColorSelect
validate_color = RegexValidator('^[0-9a-f]{6}$', 'Enter a valid hexadecimal RGB color code.', 'invalid')
ColorValidator = RegexValidator(
regex='^[0-9a-f]{6}$',
message='Enter a valid hexadecimal RGB color code.',
code='invalid'
)
class NullableCharField(models.CharField):
@@ -21,7 +26,7 @@ class NullableCharField(models.CharField):
class ColorField(models.CharField):
default_validators = [validate_color]
default_validators = [ColorValidator]
description = "A hexadecimal RGB color code"
def __init__(self, *args, **kwargs):