From febcf237ca17a986ad9485199a0a1dd1bd866057 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 19 Jul 2018 09:24:58 +0200 Subject: [PATCH] Prevent a KeyError during form validation --- src/pretix/control/forms/item.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index bf3fee8a40..77a1f03954 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -417,10 +417,11 @@ class ItemAddOnsFormSet(I18nFormSet): pass continue - if form.cleaned_data['addon_category'].pk in categories: - raise ValidationError(_('You added the same add-on category twice')) + if 'addon_category' in form.cleaned_data: + if form.cleaned_data['addon_category'].pk in categories: + raise ValidationError(_('You added the same add-on category twice')) - categories.add(form.cleaned_data['addon_category'].pk) + categories.add(form.cleaned_data['addon_category'].pk) @property def empty_form(self):