I am trying to include a field that is a property in the model_to_dict fields list.
class Person(models.Model):
thumbnail = models.ImageField(upload_to='bla...')
...snipped...
@property
def thumbnail_url(self):
return self.thumbnail.url
def toJSON(self):
return model_to_dict(self, fields=[..., 'thumbnail_url',...])
When I call Person.toJSON() it does not include thumbnail_url field.
What is wrong?
Thank you.