DRF chain fields

Hello. In my project i use DRF, now i create CreateSerializer and I want to chain two fields in the serializer. how can this be done.

Yeah, I read the article https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html but, couldn’t solve problem with drf

class CreateDISerializer(serializers.ModelSerializer):
    s = serializers.PrimaryKeyRelatedField(

    d = serializers.PrimaryKeyRelatedField(

I believe that Serializer is not the right place to put a chained logic.

The chained fields can be implemented in forms, for example. You can use django-autocomplete to use chained fields in forms. It works with DRF.