From 798f2152b5d477d192188c10580f20bbde239895 Mon Sep 17 00:00:00 2001 From: Olivier Aubert <contact@olivieraubert.net> Date: Mon, 28 Oct 2024 10:58:13 +0100 Subject: [PATCH] Fix csvimport --check command to handle missing subjects --- catalog/management/commands/csvimport.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalog/management/commands/csvimport.py b/catalog/management/commands/csvimport.py index 53340f4..5e6bc5d 100644 --- a/catalog/management/commands/csvimport.py +++ b/catalog/management/commands/csvimport.py @@ -52,7 +52,9 @@ class Command(BaseCommand): # Check that they are defined for keyword in self.get_keywords(row): - if not Subject.objects.get(label=keyword): + try: + _ = Subject.objects.get(label=keyword) + except Subject.DoesNotExist: print(f"{keyword} is not defined") def import_data(self, data): -- GitLab