diff --git a/event/models.py b/event/models.py index 064d33f..a93ea3a 100644 --- a/event/models.py +++ b/event/models.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ +from django.core.validators import RegexValidator from django.core import exceptions from django.db import models from re import search as re_search @@ -72,10 +73,16 @@ class ActivityTag(models.Model): is_public = models.BooleanField( help_text=_("TODO"), ) + color_regex = RegexValidator( + regex=r'^#(?:[0-9a-fA-F]{3}){1,2}$', + message="La chaîne de caractère rentrée n'est pas" + "une couleur en hexadécimal.", + ) color = models.CharField( _('Couleur'), max_length=7, - validators=[validate_color], + validators=[color_regex], + help_text="Rentrer une couleur en hexadécimal", ) class Meta: