django rest framework 视图不显示相关 table 数据

django rest framework view does'nt show related table data

models.py

class MEMBER(models.Model):
    LB_NAME = models.CharField(max_length=40,null=True)
    LB_FIRST_NAME = models.CharField(max_length=40,null=True)
    DT_DAT_BIRTH = models.DateField(,null=True)
    CO_ID = models.CharField(max_length=6,null=True)

class MEMBER_DECLARE_RECEPT(models.Model):
    SY_MEMBER=models.ForeignKey(MEMBER,verbose_name='Name member ',null=True,related_name='Member')
    DT_DECLARATION_RECEPT=models.DateField(('Date received',null=True)

serializers.py

class MemberSerializer(serializers.ModelSerializer):
    class Meta:
        model = MEMBER
        fields=('id','LB_NAME','LB_FIRST_NAME','CO_ID')


class MemberDeclareSerializer(serializers.ModelSerializer):
    class Meta:
        model = MEMBER_DECLARE_RECEPT
        fields=('id','SY_MEMBRE','DT_DECLARATION_RECEPT','FL_RECEPT_RECEPT_DEFAUT')

views.py

class MemberDeclareDetail(generics.ListCreateAPIView):
    queryset=MEMBER_DECLARE_RECEPT.objects.all()
    serializer_class =MemberDeclareSerializer
    def get_object(self,pk):
        try:
            return self.queryset.get(pk=pk)
        except MEMBER_DECLARE_RECEPT.DoesNotExist:
            raise Http404

    def get(self, request, pk,format=None):
        entries = self.get_object(pk)
        serializer = MemberDeclareSerializer(entries)
        return Response(serializer.data)

结果:

{
    "id": 1, 
    "SY_MEMBER": 1, 
    "DT_DECLARATION_RECEPT": "2014-12-31", 
    "FL_RECEPT_RECEPT_DEFAUT": "1"
}

但不是相关的 table 数据!

我在这里错过了什么?

你需要Serializer relations

class MemberDeclareSerializer(serializers.ModelSerializer):
    ...
    members = serializers.StringRelatedField(many=True)
    ...

此外,尽量遵循 python 命名约定

class MemberDeclareRecept(models.Model):
    member=models.ForeignKey(Member,verbose_name='Name member ',null=True,related_name='members')