diff --git a/hinghwa-dict-backend/word/character/views.py b/hinghwa-dict-backend/word/character/views.py index a3d9f159..a995f339 100644 --- a/hinghwa-dict-backend/word/character/views.py +++ b/hinghwa-dict-backend/word/character/views.py @@ -117,6 +117,12 @@ def searchCharactersPinyin(request): result1[pinyin]["characters"].append( {"character": character, "word": word, "traditional": traditional} ) + unique_result = [] + exist_set = set() + for item in result1.values(): + if item["pinyin"] not in exist_set: + unique_result.append(item) + exist_set.add(item["pinyin"]) return JsonResponse({"result": list(result1.values())}, status=200) else: return JsonResponse({}, status=405) diff --git a/hinghwa-dict-backend/word/migrations/0005_listadmin.py b/hinghwa-dict-backend/word/migrations/0005_listadmin.py deleted file mode 100644 index 7466a2d9..00000000 --- a/hinghwa-dict-backend/word/migrations/0005_listadmin.py +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by Django 3.1.14 on 2023-09-16 08:49 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("word", "0004_word_list"), - ] - - operations = [ - migrations.AlterModelOptions( - name="list", - options={"verbose_name": "词单", "verbose_name_plural": "词单"}, - ), - ]