D
D
Domohod2021-12-12 10:32:37
Django
Domohod, 2021-12-12 10:32:37

Why are png images not showing in django?

I'm using django-avatar to allow people to upload their own avatars. Jpg images are displayed correctly, but png are not:
61b5a46a9f5dd173776813.png
I think my image display is set up correctly.

settings.py:

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

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


URLs.py:
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Here's what I include in the template:
{% load avatar_tags %}
{% render_avatar avatar 250 %}
{% load account %}
{% user_display user %}
{% load i18n %}
{% load static %}

But that doesn't help, with some pngs showing and others not.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Domohod, 2021-12-12
@Domohod

I DECIDED! For everything to work, you just need to register in settings.py:
AVATAR_THUMB_FORMAT = 'PNG'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question