[Fixed]-Displaying image file from django model in jade

1👍

MEDIA_ROOT is an absolute path and you can set the path in your settings.py file like following:

MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images/upload')

And change your FileField to ImageField

photo = models.ImageField(null=True, upload_to= 'brands')

And, you can access the object photo as follows:

 <img src="{{ object.photo.url }}">

Leave a comment