title: How to check (in template) if user belongs to a group
body: <p>How to check in template whether user belongs to some group? </p>
  
  <p>It is possible in a <code>view</code> which is generating the <code>template</code> but what if I want to check this in <code>base.html</code> which is an extending template (it does not have it's own view function)?</p>
  
  <p>All of my templates extends <code>base.html</code> so it is not good to check it in each <code>view</code>. </p>
  
  <p>The <code>base.html</code> contains upper bar, which should contain buttons depending on in which <code>group</code> logged user is (Customers, Sellers).  </p>
  
  <p>In my <code>base.html</code> is:</p>
  
  <pre><code>{% if user.is_authenticated %}
  </code></pre>
  
  <p>which is not enough because I have to act differently to users from <code>Customers</code> and users from <code>Sellers</code>.</p>
  
  <p>So the thing I want is:</p>
  
  <pre><code>{% if user.in_group('Customers') %}
   &lt;p&gt;Customer&lt;/p&gt;
  {% endif %}
  {% if user.in_group('Sellers') %}
  &lt;p&gt;Seller&lt;/p&gt;
  {% endif %}
  </code></pre>