From d235f61e5aae81030583c57ff2d731e7007753c7 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 30 Jun 2020 13:18:54 +0200 Subject: [PATCH] Clean other editor when a real editor is found --- manuels/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manuels/models.py b/manuels/models.py index 841bf67..2eb3ccd 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -290,8 +290,12 @@ class Book(BaseModel): potential_editor = ( Editor.objects.filter(name__iexact=editor).first() or Editor.objects.filter(name__icontains=editor).first() - or Editor.objects.get(name__istartswith="autre") ) + if potential_editor: + self.other_editor = "" + else: + potential_editor = Editor.objects.get(name__istartswith="autre") + self.other_editor = editor self.editor = potential_editor self.save()