From 75d62014fb9c092e859b575c9f04ec13d37ccbf7 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Wed, 18 Dec 2024 23:13:56 +0800 Subject: [PATCH] Fix error with questionnaire submissions not tied to requests --- docmanager_backend/questionnaires/serializers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docmanager_backend/questionnaires/serializers.py b/docmanager_backend/questionnaires/serializers.py index c20d43e..ddb0385 100644 --- a/docmanager_backend/questionnaires/serializers.py +++ b/docmanager_backend/questionnaires/serializers.py @@ -69,7 +69,10 @@ class QuestionnaireSerializer(serializers.ModelSerializer): ) if "document_request" in validated_data: - document_request_id = validated_data["document_request"].id + if validated_data["document_request"]: + document_request_id = validated_data["document_request"].id + else: + document_request_id = None del validated_data["document_request"] instance = self.Meta.model(**validated_data)