mirror of
https://github.com/lemeow125/Django-NotesApp.git
synced 2024-11-17 06:29:25 +08:00
13 lines
411 B
Python
13 lines
411 B
Python
from django.contrib.auth.models import User
|
|
from rest_framework import serializers
|
|
from notes.models import Note
|
|
|
|
|
|
class CustomUserSerializer(serializers.ModelSerializer):
|
|
notes = serializers.PrimaryKeyRelatedField(
|
|
many=True, allow_null=True, read_only=True)
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ['id', 'username', 'notes']
|
|
read_only_fields = ['id', 'notes']
|