mirror of
https://github.com/lemeow125/Django-NotesApp.git
synced 2024-11-17 06:29:25 +08:00
Fixed user serializer error when specifying notes relationship
This commit is contained in:
parent
bad4d4d647
commit
a64294a5a8
1 changed files with 2 additions and 2 deletions
|
@ -5,9 +5,9 @@ from notes.models import Note
|
||||||
|
|
||||||
class CustomUserSerializer(serializers.ModelSerializer):
|
class CustomUserSerializer(serializers.ModelSerializer):
|
||||||
notes = serializers.PrimaryKeyRelatedField(
|
notes = serializers.PrimaryKeyRelatedField(
|
||||||
many=True, allow_null=True, queryset=Note.objects.all())
|
many=True, allow_null=True, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['id', 'username', 'notes',]
|
fields = ['id', 'username', 'notes']
|
||||||
read_only_fields = ['id', 'notes']
|
read_only_fields = ['id', 'notes']
|
||||||
|
|
Loading…
Reference in a new issue