Created
October 6, 2021 09:51
-
-
Save TSKGunGun/94412748065f6e4527d4bb54fcae15d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create your models here. | |
from django.db import models | |
from django.core.validators import RegexValidator | |
class NumValidator(RegexValidator): | |
regex = r'^[0-9]+\Z' | |
message = "ゼッケンNoは数字のみで入力してください。" | |
def __call__(self, value): | |
return super().__call__(value) | |
class Foo(models.Model): | |
val = NumValidator() | |
num = models.CharField(verbose_name="番号", max_length=10, null=False, validators=[val]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment