O
O
Ozrae2020-07-23 20:28:54
Django
Ozrae, 2020-07-23 20:28:54

Why is the image not showing on the page?

My django is broken, it thinks that I forgot to write {% endblock %} and gives the following error:

TemplateSyntaxError at /articles/asdas/
Invalid block tag on line 19: 'static', expected 'endblock'. Did you forget to register or load this tag?


This happened after I tried to add an image to the page. Here are my static files settings:
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'assets')
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

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


And here is the html document itself, marked with a comment the line where I added the image, as you can see, the "endblock" is there, at the very end of the document:

{% extends 'base_layout.html' %}

{% block content %}
    <div class='detail-container'>
        <div class='article-detail'>
            <img src='{{ article.thumb.url }}'>
            {% if article.tags %}
            <div class='tags'>
                {% for tag in article.tags.all %}
                    <span>{{ tag.title }}</span>
                {% endfor %}
            </div>
            {% endif %}
            </img>
            <h2>{{ article.title }}</h2>
            <p>{{ article.body }}</p>
            <h3>Written by {{ article.author.username }}</h3>
            <p>{{ article.date }}</p>
            <img src="{% static 'app/add.png' %}">  <!-- вот здесь -->
        </div>
    </div>
{% endblock %}


How to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-07-23
@Ozrae

it's probably hard to read the docs first https://docs.djangoproject.com/en/3.0/ref/template...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question