Add slug validator for org
This commit is contained in:
parent
3791d2e90f
commit
08fae0d0dc
2 changed files with 32 additions and 0 deletions
29
judge/migrations/0146_alter_organization_slug.py
Normal file
29
judge/migrations/0146_alter_organization_slug.py
Normal 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",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -34,6 +34,9 @@ class Organization(models.Model):
|
|||
verbose_name=_("organization slug"),
|
||||
help_text=_("Organization name shown in URL"),
|
||||
unique=True,
|
||||
validators=[
|
||||
RegexValidator("^[-a-zA-Z0-9]+$", _("Only alphanumeric and hyphens"))
|
||||
],
|
||||
)
|
||||
short_name = models.CharField(
|
||||
max_length=20,
|
||||
|
|
Loading…
Reference in a new issue