Skip to content

'Edit appointment' throws error

In Edit appointment after I unticked checkbox in Appointment types, and tried to SAVE the change, below error was thrown.
I have privilege web | appointment type | Can change appointment type.

Screen_Shot_2021-03-23_at_11.47.40

Screen_Shot_2021-03-23_at_11.47.44

Environment:      
Request Method: POST
Request URL: http://pdp-test.lcsb.uni.lu/appointments/edit/50

Django Version: 3.1.4
Python Version: 3.6.13
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_cleanup',
 'django_cron',
 'django_otp',
 'django_otp.plugins.otp_static',
 'django_otp.plugins.otp_totp',
 'two_factor',
 'web',
 'stronghold',
 'debug_toolbar']
Installed Middleware:
['web.middleware.PrivacyNoticeMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'stronghold.middleware.LoginRequiredMiddleware']



Traceback (most recent call last):
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/utils/datastructures.py", line 76, in __getitem__
    list_ = super().__getitem__(key)
When I `Appointment types 

During handling of the above exception ('appointment_types'), another exception occurred:
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/smasch/web/views/appointment.py", line 112, in appointment_edit
    if not appointment_form.is_valid():
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/forms/forms.py", line 177, in is_valid
    return self.is_bound and not self.errors
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/forms/forms.py", line 172, in errors
    self.full_clean()
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/forms/forms.py", line 375, in full_clean
    self._clean_form()
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/forms/forms.py", line 402, in _clean_form
    cleaned_data = self.clean()
  File "/usr/lib/smasch/web/forms/appointment_form.py", line 115, in clean
    self.register_changes()  # right before instance is changed
  File "/usr/lib/smasch/web/forms/appointment_form.py", line 35, in register_changes
    new_value = self.cleaned_data[field] or self.data[field]
  File "/usr/lib/smasch/env/lib/python3.6/site-packages/django/utils/datastructures.py", line 78, in __getitem__
    raise MultiValueDictKeyError(key)

Exception Type: MultiValueDictKeyError at /appointments/edit/50
Exception Value: 'appointment_types'
Edited by Piotr Gawron