浏览代码

Bug: Correct length of classifier term length to 255 (#589)

#### Description of change
Changes the maximum length of the slug field of ClassifierTerm to have a
maximum length of 255, to match the name. This is also the maximum
length that several django backends allow for unique fields:
https://docs.djangoproject.com/en/4.2/ref/databases/#character-fields

#### Tests
Created a test project, ensured that a field with a name of a length
greater than 50 did not cause errors.

NOTES: This was believed to be fixed in 2.1.3, but that only corrected
the slug field on classifiers, not classifier terms.
Jeremy Childers 1 年之前
父节点
当前提交
56acc29de4
共有 2 个文件被更改,包括 23 次插入0 次删除
  1. 22 0
      coderedcms/migrations/0039_alter_classifierterm_slug.py
  2. 1 0
      coderedcms/models/snippet_models.py

+ 22 - 0
coderedcms/migrations/0039_alter_classifierterm_slug.py

@@ -0,0 +1,22 @@
+# Generated by Django 4.1.10 on 2023-07-13 19:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("coderedcms", "0038_alter_classifier_slug"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="classifierterm",
+            name="slug",
+            field=models.SlugField(
+                allow_unicode=True,
+                max_length=255,
+                unique=True,
+                verbose_name="Slug",
+            ),
+        ),
+    ]

+ 1 - 0
coderedcms/models/snippet_models.py

@@ -189,6 +189,7 @@ class ClassifierTerm(Orderable, models.Model):
         allow_unicode=True,
         unique=True,
         verbose_name=_("Slug"),
+        max_length=255,
     )
     name = models.CharField(
         max_length=255,