我得到的TypeError: 'FieldFile' object is not callable
试图获得上传文件的URL时:
class FetchedDataSerializer(serializers.ModelSerializer):
file_fields = serializers.SerializerMethodField()
class Meta:
model = FetchedData
fields = ('model_id', 'config_id', 'config_name', 'file_fields')
def get_file_fields(self, obj):
queryset = obj.config_id.config_file() ###
return ShoppingListSerializer(queryset, many=True).data
该模型包括以下字段:
class ShoppingList(models.Model):
id = models.CharField(max_length=40, primary_key=True)
name = models.CharField(max_length=40)
session_id = models.CharField(max_length=40)
config_file = models.FileField(upload_to=upload_config_file)
def __str__(self):
return self.id
我应该用做queryset
,最终显示上传的文件URL?