validator for subdomain

This commit is contained in:
Arne Schauf 2013-09-29 13:47:02 +02:00
parent 332acdf469
commit 6a8707e2c6

View File

@ -18,7 +18,8 @@ class Domain(models.Model):
class Host(models.Model): class Host(models.Model):
"""TODO: hash update_secret on save (if not already hashed)""" """TODO: hash update_secret on save (if not already hashed)"""
#fqdn = models.CharField(max_length=256, unique=True, verbose_name="Fully qualified domain name") #fqdn = models.CharField(max_length=256, unique=True, verbose_name="Fully qualified domain name")
subdomain = models.CharField(max_length=256) subdomain = models.CharField(max_length=256, validators=[
RegexValidator(regex=r'^(([a-z0-9][a-z0-9\-]*[a-z0-9])|[a-z0-9])$', message='Invalid subdomain: only letters, digits and dashes are allowed')])
domain = models.ForeignKey(Domain) domain = models.ForeignKey(Domain)
update_secret = models.CharField(max_length=256) update_secret = models.CharField(max_length=256)
comment = models.CharField(max_length=256, default='', blank=True, null=True) comment = models.CharField(max_length=256, default='', blank=True, null=True)