【问题标题】:Django Rest Framework Serialization error in ListAPIViewListAPIView 中的 Django Rest Framework 序列化错误
【发布时间】:2016-05-07 07:25:25
【问题描述】:

我遇到了错误

错误 -- 'many' 是此函数的无效关键字参数"

序列化对象时在 ListAPIView 中。

class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = User
        fields = ('id', 'uuid', 'email', 'password', 'first_name', 'last_name', 'mobile_no', 'dob', 'username',)


class CorporateProfileSerializer(serializers.ModelSerializer):
     user = UserSerializer(many=True)

     class Meta:
        model = CorporateProfile
        fields = ('user', 'id', 'uuid', 'company_name', 'company_type',)

views.py

class CorporateListView(ListAPIView):
    serializer_class = CorporateProfile
    queryset = CorporateProfile.objects.all()

我在这里做错了什么?

【问题讨论】:

    标签: python django django-rest-framework django-generic-views


    【解决方案1】:

    我的观点有误。我在序列化程序类而不是序列化程序类中编写模型。

    serializer_class = CorporateProfileSerializer
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-21
      • 1970-01-01
      • 2020-05-23
      • 2019-05-23
      • 2020-12-09
      • 1970-01-01
      • 2021-04-29
      • 1970-01-01
      相关资源
      最近更新 更多