Fix KeyError in modelFieldDescriptions

on older Anki versions, where field descriptions aren't available
This commit is contained in:
introt 2022-11-27 12:19:58 +02:00
parent 336dc8bb31
commit ff4fb13428

View File

@ -1075,7 +1075,12 @@ class AnkiConnect:
if model is None: if model is None:
raise Exception('model was not found: {}'.format(modelName)) raise Exception('model was not found: {}'.format(modelName))
else: else:
return [field['description'] for field in model['flds']] try:
return [field['description'] for field in model['flds']]
except KeyError:
# older versions of Anki don't have field descriptions
return ['' for field in model['flds']]
@util.api() @util.api()