Skip to content

Commit 986574f

Browse files
committed
Fix KeyError for type
Not all fields are always present. When changing an attribute type is not present in the form because it can only be setup during Attribute creation.
1 parent 14561cd commit 986574f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

serveradmin/serverdb/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class Meta:
4141
fields = '__all__'
4242

4343
def clean(self):
44-
if self.cleaned_data['type'] != 'relation' and self.cleaned_data['target_servertype'] is not None:
44+
if self.cleaned_data.get('type') != 'relation' and self.cleaned_data.get('target_servertype') is not None:
4545
raise ValidationError('Attribute type must be relation when target servertype is selected!')
4646

47-
if self.cleaned_data['type'] == 'inet' and self.cleaned_data['multi'] is True:
47+
if self.cleaned_data.get('type') == 'inet' and self.cleaned_data.get('multi') is True:
4848
raise ValidationError('Multi attributes of type inet are not supported!')
4949

5050
super().clean()

0 commit comments

Comments
 (0)