I read a lot of questions and articles, but I can not find what I am missing.
Here is my conf:
settings.py
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(os.path.dirname(__file__),'static').replace('\\', '/'), )
urls.py
urlpatterns = [ url(r'^$', include('home.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^artist/', include('artists.urls')), url(r'photo/', include('photo.urls')) ] urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Be that as it may, my media is being served because when I go to http: // localhost: 8000 / media / path / to / image.jpg , I have my image.
But when in the template I go like this:
<img class="avatar secondary-content" src="{{MEDIA_URL}}{{artist.artist_image}}">
I have only the path to the image. When I change the html {{MEDIA_URL}} to '/ media /', it works.
So, my MEDIA_URL not set in the template, and as far as I was looking, I do not see what I missed.
I'm on django 1.8.2. If you need information, just ask me.
Bestasttung Aug 10 '15 at 16:48 2015-08-10 16:48
source share