I\'ve defined a simple Django app that includes the following model:
class Project(models.Model):
name = models.CharField(max_length=200)
thumbnail =
To get the url of a file which uses FileField you can just call the url attribute of the FieldFile (this is the file instance not the field), it use the Storage class to determine the url for this file. It's very straightforward if you are using a external storage like Amazon S3 or if your storage changes.
The get_thumbnail_url would be like this.
def get_thumbnail_url(self, obj):
return obj.thumbnail.url
You can also use it in the template this way:
{{ current_project.thumbnail.url }}