DEV Community

Isaac Hatilima
Isaac Hatilima

Posted on

Django Rest Framework

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

Top comments (0)