How to check in template whether user belongs to some group?
It is possible in a view which is generating the template but what if I want
You can use this:
{% for group_for in request.user.groups.all %}
{% if group_for.name == 'Customers' %}
Text showed to users in group 'Customers'
{% elif group_for.name == 'Sellers' %}
Text showed to users in group 'Sellers'
{% endif %}
{% endfor %}
This is iterating through groups related to the user who makes the request and printing the text if the name of the iterated group equals 'Customers', 'Sellers', etc