I don't know how this can happen, perhaps a race-condition where while a plan is being edited, the template is deleted?
Internal Server Error: /plan/template/2/
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 172, in post
return super().post(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 141, in post
if form.is_valid():
File "/usr/local/lib/python3.10/site-packages/django/forms/forms.py", line 175, in is_valid
return self.is_bound and not self.errors
File "/usr/local/lib/python3.10/site-packages/django/forms/forms.py", line 170, in errors
self.full_clean()
File "/usr/local/lib/python3.10/site-packages/django/forms/forms.py", line 374, in full_clean
self._post_clean()
File "/usr/local/lib/python3.10/site-packages/django/forms/models.py", line 413, in _post_clean
self.instance.full_clean(exclude=exclude, validate_unique=False)
File "/usr/local/lib/python3.10/site-packages/django/db/models/base.py", line 1236, in full_clean
self.clean()
File "/app/src/easydmp/plan/models.py", line 887, in clean
for section in self.template.sections.all():
File "/usr/local/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 197, in __get__
raise self.RelatedObjectDoesNotExist(
easydmp.plan.models.Plan.template.RelatedObjectDoesNotExist: Plan has no template.
In this case, show the user an error-message and go back to the home page.
I don't know how this can happen, perhaps a race-condition where while a plan is being edited, the template is deleted?
In this case, show the user an error-message and go back to the home page.