11279 add collation

This commit is contained in:
Arthur Hanson 2024-11-12 14:41:54 -08:00
parent 03d413565f
commit 4062986e06
3 changed files with 44 additions and 2 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 5.0.9 on 2024-11-12 22:21
from django.contrib.postgres.operations import CreateCollation
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('dcim', '0196_qinq_svlan'),
]
operations = [
CreateCollation(
"natural_sort",
provider="icu",
locale="und-u-kn-true",
),
]

View File

@ -0,0 +1,22 @@
# Generated by Django 5.0.9 on 2024-11-12 22:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0197_auto_20241112_2221'),
]
operations = [
migrations.AlterModelOptions(
name='site',
options={'ordering': ('name',)},
),
migrations.AlterField(
model_name='site',
name='name',
field=models.CharField(db_collation='natural_sort', max_length=100, unique=True),
),
]

View File

@ -143,7 +143,8 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
verbose_name=_('name'),
max_length=100,
unique=True,
help_text=_("Full name of the site")
help_text=_("Full name of the site"),
db_collation="natural_sort"
)
_name = NaturalOrderingField(
target_field='name',
@ -245,7 +246,7 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
)
class Meta:
ordering = ('_name',)
ordering = ('name',)
verbose_name = _('site')
verbose_name_plural = _('sites')