B
B
blackbb2022-04-17 23:59:56
Django
blackbb, 2022-04-17 23:59:56

Why are media files not showing up in heroku?

Uploaded a django project to heroku.

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

If debug=False, it gives a 500 error, if True, it does not load media files that go through the thumbnail in the template
{% thumbnail item.image '282x160' crop='center' as im %}
                                    <img class="lazyOwl" data-src="{{ im.url }}" alt="{{ im.name }}">
                                {% endthumbnail %}

If you remove the thumbnail, then it displays normally. Cache/ is added to the path to the image, I think this is the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question