我正在使用Django REST Framework和django-gm2m应用程序:
models.py
class DocIncome(models.Model):
doc_date = models.DateTimeField()
doc_num = models.IntegerField(unique_for_date='doc_date')
follower = GM2MField()
serializers.py
class DocIncomeSerializer(serializers.ModelSerializer):
class Meta:
model = models.DocIncome
exclude = ()
views.py
class DocIncomeViewSet(viewsets.ModelViewSet):
serializer_class = serializers.DocIncomeSerializer
queryset = DocIncome.objects.all()
但是我打开api url却收到错误-
异常值:“ GM2MField”对象没有属性“ get_limit_choices_to”
异常位置:get_relation_kwargs中的C:\ Users \ konyshev.na \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ rest_framework \ utils \ field_mapping.py,第252行
有人知道如何解决吗?