I'm getting the TypeError: 'FieldFile' object is not callable
when trying to get URL of uploaded file:
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
The model consists of the following fields:
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
What should be done with the queryset
to eventually display uploaded file URL?