O
O
Ozrae2020-06-02 19:10:26
Django
Ozrae, 2020-06-02 19:10:26

How to remove empty spaces under images in posts?

I have the following cards:
5ed678a269f07642122605.png

I need to make it so that if the picture was loaded when creating the post, it will be displayed, and if the picture was not loaded, then text will be displayed in its place or there will be another display of the card. How to write such a condition? Is it written directly in the html file?

Here is the card code:

<div class='cont-class'>
    <div class='articles'>
        {% for article in page_obj.object_list %}
            <div class='article'>
                <img class='card-img' src='{{ article.thumb.url }}'>
                <h2><a href="{% url 'article:detail' slug=article.slug %}">{{ article.title }}</a></h2>
                <p>{{ article.snippet }}</p>
                <p>{{ article.date }}</p>
                <p class='author'>added by {{ article.author.username }}</p>
            </div>
        {% endfor %}
    </div>


All pictures are stored in os.path.join(BASE_DIR, 'media').

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-06-02
@Ozrae

if article.thumb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question