DEV Community

loading...

Django Rest Framework

isaachatilima profile image Isaac Hatilima ・1 min read

Hi everyone,
I have two models Clients and Users and I have serializers for the two models. If I add depth=1 in my UserSerializer then I can not add a record, but if I remove it then I am able to add a record, what am I doing wrong?

# My Client Serializer
  class ClientSerializer(serializers.ModelSerializer):
    class Meta:
      model = Clients
      fields = '__all__'
      read_only_fields = ('id','client_public_key')


# My User Serializer
  class UserSerializer(serializers.ModelSerializer):
    class Meta:
      model = Users
      depth = 1
      fields = '__all__'
      read_only_fields = ('id','user_public_key')
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide