title: How to get group of currently logged in user
body: <p>How to get group of currently logged in user?
  I have basic users from <strong>django.contrib.auth</strong> grouped into two groups: <strong>student</strong>, <strong>teacher</strong>.
  I want to show the group of currently logged in user in following template:</p>
  <pre><code>{% block content %}
      &lt;h2&gt;
        Witaj {{ user.first_name }} {{ user.last_name }}  !
      &lt;/h2&gt;
  {% endblock %}
  </code></pre>
  <p>This is my views.py file:</p>
  <pre><code>def login(request):
      username = request.POST.get('username')
      password = request.POST.get('password')
      user = authenticate(request, username=username, password=password)
      if user is not None:
          login(request, user)
      else:
          return index(request)
  
  def index(request):
      return render(request, 'index.html')
  
  def logout(request):
          logout(request)
  </code></pre>