I am trying to deploy a site on heroku that has media files (images I uploaded to a database) and am confused how to display them in production mode. I have my images stored in my media directory.
settings.py
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
urls.py
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
models.py
class Project(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=250)
tools = models.CharField(max_length=200, default="Some String")
#image is stored in media/portfolio/images
image = models.ImageField(upload_to='portfolio/images')
url = models.URLField(blank=True)
def _str_(self):
return self.title