The below model has a regex validator, however, when creating new objects (with standard model instantiation and model.objects.create() ), there is no error message given when creating an object that violates the validator. It allows the object to be saved.
Below is the code for the model:
class Area(models.Model):
area = models.CharField(max_length=6, validators=[RegexValidator(
regex='^[A-Z]{1,2}[0-9][A-Z0-9]?$',
message='Area is not in correct format',
code='invalid_area'
)])
Any advise would be much appreciated.