K
K
Kirill Pisarev2015-07-25 15:56:52
Django
Kirill Pisarev, 2015-07-25 15:56:52

Why are images not showing in Django?

Hello. Just started my journey of learning Django. Faced the following problem. I'm using Django-Avatars as an application to upload and display avatars to users.
Next code:
Settings: Template:
AVATAR_STORAGE_DIR = 'media/avatars'

{% extends "base.html" %}
    <title>{% block title %} Posts {% endblock %}</title>
{% block content %}
{% load avatar_tags %}

        {{post.post_user_id}}
        {% avatar post.post_user_id %}
    <h1>{{ post.title }}</h1>
<hr>
    <h2>{{ post.content }}</h2>

Images are loaded without problems in the path specified in AVATAR_STORAGE_DIR. However, they are not displayed in the browser.
d1d07b1345144003976912383fce8e1f.png
In the console, you can see that Django returns 404 when accessed along the avatar path, although, once again, everything is ok with loading.
07bedcd1dd684342bfa1ba7b46b9a06f.png
Perhaps Django-Avatar itself is a crutch? And is it worth writing something yourself ...?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Sklyar, 2015-07-25
@P1sar

Hello. Add photo to profile page using thubnails? Look at what you need to register in the yurla, it helped me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question