From a64294a5a8406e240a0b11131ff0d6c757acc173 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sun, 26 Mar 2023 13:49:19 +0800 Subject: [PATCH] Fixed user serializer error when specifying notes relationship --- project/accounts/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/accounts/serializers.py b/project/accounts/serializers.py index 2d990c4..e0f27bd 100644 --- a/project/accounts/serializers.py +++ b/project/accounts/serializers.py @@ -5,9 +5,9 @@ from notes.models import Note class CustomUserSerializer(serializers.ModelSerializer): notes = serializers.PrimaryKeyRelatedField( - many=True, allow_null=True, queryset=Note.objects.all()) + many=True, allow_null=True, read_only=True) class Meta: model = User - fields = ['id', 'username', 'notes',] + fields = ['id', 'username', 'notes'] read_only_fields = ['id', 'notes']