From 831a98378108278c99209ceb955731b89bebd094 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Wed, 28 Jul 2021 16:58:06 +0200 Subject: [PATCH] Automatically set the creator on newly posted semantic queries (#486) --- backend/items/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/items/serializers.py b/backend/items/serializers.py index f435ecc7..07b63a43 100644 --- a/backend/items/serializers.py +++ b/backend/items/serializers.py @@ -7,3 +7,7 @@ class SemanticQuerySerializer(serializers.ModelSerializer): class Meta: model = SemanticQuery fields = ['id', 'label', 'query'] + + def create(self, validated_data): + validated_data['creator'] = self.context['request'].user + return super().create(validated_data)