Add slug validator for org

This commit is contained in:
cuom1999 2023-01-25 13:13:42 -06:00
parent 3791d2e90f
commit 08fae0d0dc
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,29 @@
# Generated by Django 3.2.16 on 2023-01-25 19:12
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("judge", "0145_alter_organization_slug"),
]
operations = [
migrations.AlterField(
model_name="organization",
name="slug",
field=models.SlugField(
help_text="Organization name shown in URL",
max_length=128,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[-a-zA-Z0-9]+$", "Only alphanumeric and hyphens"
)
],
verbose_name="organization slug",
),
),
]

View file

@ -34,6 +34,9 @@ class Organization(models.Model):
verbose_name=_("organization slug"), verbose_name=_("organization slug"),
help_text=_("Organization name shown in URL"), help_text=_("Organization name shown in URL"),
unique=True, unique=True,
validators=[
RegexValidator("^[-a-zA-Z0-9]+$", _("Only alphanumeric and hyphens"))
],
) )
short_name = models.CharField( short_name = models.CharField(
max_length=20, max_length=20,