diff --git a/netbox/extras/migrations/0092_delete_jobresult.py b/netbox/extras/migrations/0092_delete_jobresult.py index c1b121c69..e794ba616 100644 --- a/netbox/extras/migrations/0092_delete_jobresult.py +++ b/netbox/extras/migrations/0092_delete_jobresult.py @@ -1,6 +1,8 @@ # Generated by Django 4.1.7 on 2023-03-27 17:31 -from django.db import migrations +import django.core.validators +from django.db import migrations, models +import re class Migration(migrations.Migration): @@ -13,4 +15,24 @@ class Migration(migrations.Migration): migrations.DeleteModel( name='JobResult', ), + migrations.AlterField( + model_name='customfield', + name='name', + field=models.CharField( + max_length=50, + unique=True, + validators=[ + django.core.validators.RegexValidator( + flags=re.RegexFlag['IGNORECASE'], + message='Only alphanumeric characters and underscores are allowed.', + regex='^[a-z0-9_]+$', + ), + django.core.validators.RegexValidator( + flags=re.RegexFlag['IGNORECASE'], + message='No double-underscores are allowed.', + regex='^(?!.*__.*)', + ), + ], + ), + ), ] diff --git a/netbox/extras/migrations/0093_alter_customfield_name.py b/netbox/extras/migrations/0093_alter_customfield_name.py deleted file mode 100644 index dfdcd2ec3..000000000 --- a/netbox/extras/migrations/0093_alter_customfield_name.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 4.1.8 on 2023-05-08 15:57 - -import django.core.validators -from django.db import migrations, models -import re - - -class Migration(migrations.Migration): - dependencies = [ - ('extras', '0092_delete_jobresult'), - ] - - operations = [ - migrations.AlterField( - model_name='customfield', - name='name', - field=models.CharField( - max_length=50, - unique=True, - validators=[ - django.core.validators.RegexValidator( - flags=re.RegexFlag['IGNORECASE'], - message='Only alphanumeric characters and underscores (no double-underscores) are allowed.', - regex='^(?!.*__.*)^[a-z0-9_]+$', - ) - ], - ), - ), - ] diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index 635f9c882..c951a5675 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -81,8 +81,13 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel): help_text=_('Internal field name'), validators=( RegexValidator( - regex=r'^(?!.*__.*)^[a-z0-9_]+$', - message="Only alphanumeric characters and underscores (no double-underscores) are allowed.", + regex=r'^[a-z0-9_]+$', + message="Only alphanumeric characters and underscores are allowed.", + flags=re.IGNORECASE + ), + RegexValidator( + regex=r'^(?!.*__.*)', + message="No double-underscores are allowed.", flags=re.IGNORECASE ), )