Misc cleanup
This commit is contained in:
@@ -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):
|
||||
|
Reference in New Issue
Block a user