1
votes

In Django 3 I have this in my settings: MEDIA_URL = '/media/'

My MEDIA_ROOT echos out properly (/home/bradrice/source/repos/bb_backend/media ) and I have this in my urls:

if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I am using a VersatileImageField and the image uploads to the proper media folder. However, I can't see the image in Admin and if I click the link it prepends the Url with the full MEDIA_ROOT instead of just the /media/ onto the display url.

What am I doing wrong.

1

1 Answers

1
votes

My error. In my models I had this code to make the upload path:

def artwork_directory_path(instance, filename):

# file will be uploaded to MEDIA_ROOT / user_<id>/<filename> 
return MEDIA_ROOT + '/artwork/{0}'.format(filename) 

then in my image model I had upload_to=artwork_directory_path.

I just hardcoded it to upload_to="artwork" and everything started working.