1
0
Fork 0

strip leading and following spaces from ISBN

This commit is contained in:
Hugh Rundle 2022-08-28 17:28:00 +10:00
parent da5fd32196
commit f219851f3a
2 changed files with 3 additions and 4 deletions

View file

@ -32,7 +32,7 @@ def isbn_search(query):
return []
# Up-case the ISBN string to ensure any 'X' check-digit is correct
# If the ISBN has only 9 characters, prepend missing zero
query = query.upper().rjust(10, '0')
query = query.strip().upper().rjust(10, '0')
filters = [{f: query} for f in ["isbn_10", "isbn_13"]]
results = models.Edition.objects.filter(
reduce(operator.or_, (Q(**f) for f in filters))