title: How to check current user's permissions from a Group in Django?
body: <p>I have a group <code>EuropartsBuyer</code> and model named <code>Product</code>.</p>
  
  <p>The following code adds a permission to the Product model.</p>
  
  <pre><code>class Meta:
          permissions = (
              ("can_add_cost_price", "Can add cost price"),
          )
  </code></pre>
  
  <p>In one of my views I have the following code to add this permission to that group.</p>
  
  <pre><code>europarts_buyer, created = Group.objects.get_or_create(name='EuropartsBuyer')
  add_cost_price = Permission.objects.get(codename='can_add_cost_price')
  europarts_buyer.permissions.add(add_cost_price)
  </code></pre>
  
  <p>With the help of Django Admin I have added a user to the group <code>EuropartsBuyer</code>.</p>
  
  <p>When I use the following code in another view</p>
  
  <pre><code>if request.user.has_perm('can_add_cost_price'):
      do something
  </code></pre>
  
  <p>the result is supposed to be <code>True</code> but it is showing <code>False</code>. Thus, the code under the if clause doesn't run.</p>
  
  <p>I have imported the currently logged in user in Django shell and when I test the permission again it shows False.</p>
  
  <p>What am I doing wrong here?</p>