diff --git a/apps/core/migrations/0052_alter_board_slug.py b/apps/core/migrations/0052_alter_board_slug.py new file mode 100644 index 00000000..ef653604 --- /dev/null +++ b/apps/core/migrations/0052_alter_board_slug.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.3 on 2023-07-21 04:48 + +from django.db import migrations +import django_extensions.db.fields + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0051_remove_board_en_description_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="board", + name="slug", + field=django_extensions.db.fields.AutoSlugField( + blank=True, editable=False, populate_from=["en_name"], unique=True + ), + ), + ] diff --git a/apps/core/models/board.py b/apps/core/models/board.py index b1d7187a..6bbeec4b 100644 --- a/apps/core/models/board.py +++ b/apps/core/models/board.py @@ -20,9 +20,8 @@ class BoardAccessPermissionType(IntEnum): class Board(MetaDataModel): slug = AutoSlugField( - populate_from=[ - "en_name", - ], + populate_from=["en_name"], + unique=True, ) ko_name = models.CharField( verbose_name="게시판 국문 이름", diff --git a/apps/core/views/viewsets/board.py b/apps/core/views/viewsets/board.py index c59a8083..c7b282f1 100644 --- a/apps/core/views/viewsets/board.py +++ b/apps/core/views/viewsets/board.py @@ -14,3 +14,4 @@ class BoardViewSet(viewsets.ReadOnlyModelViewSet, ActionAPIViewSet): action_serializer_class = { "list": BoardDetailActionSerializer, } + lookup_field = "slug"