1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #1838: Fix KeyError when attempting to create a VirtualChassis with no devicesselected

This commit is contained in:
Jeremy Stretch
2018-01-30 16:42:52 -05:00
parent 1cd629efb3
commit 8b6d731cb6

View File

@ -2044,7 +2044,11 @@ class VirtualChassisCreateView(PermissionRequiredMixin, View):
# Get the list of devices being added to a VirtualChassis # Get the list of devices being added to a VirtualChassis
pk_form = forms.DeviceSelectionForm(request.POST) pk_form = forms.DeviceSelectionForm(request.POST)
pk_form.full_clean() pk_form.full_clean()
device_list = pk_form.cleaned_data['pk'] device_list = pk_form.cleaned_data.get('pk')
if not device_list:
messages.warning(request, "No devices were selected.")
return redirect('dcim:device_list')
# Generate a custom VCMembershipForm where the device field is limited to only the selected devices # Generate a custom VCMembershipForm where the device field is limited to only the selected devices
class _VCMembershipForm(forms.VCMembershipForm): class _VCMembershipForm(forms.VCMembershipForm):