A
A
Arsen Abakarov2016-09-25 00:52:43
Django
Arsen Abakarov, 2016-09-25 00:52:43

Django and empty enclosing tag context?

There is an include tag associated with the product card, it works like this:

@register.inclusion_tag('shop/shop__p-card.html')
def get_products(filt):
    products = models.Products.objects.prefetch_related('shop_positions_related').prefetch_related('photos')
    products = products.filter(**filt)
    return {'products': products}

Now imagine the situation, I have, for example, related products, if they are, I must display the title and these products, if they are not, then I should not display anything, but how can I find out?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-09-25
@ArsenAbakarov

https://docs.djangoproject.com/en/1.10/ref/templat...

{% if products %}
{%else %}
{%endif%}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question