title: Manytomanyfields issue : Fetch the columns where the manytomanyfield is applied
body: <p>(Sorry for the inappropriate title. I am very bad at english. So I couldn't find out what should be the title)</p>
  <p>I have 2 tables Devices and groups</p>
  <pre><code>class Devices(models.Model):
      id = models.AutoField(primary_key=True)
      device_name =\
          models.CharField(max_length=100, null=False)
  
  class Groups(models.Model):
      group_id = models.AutoField(primary_key=True)
      devices = models.ManyToManyField(Devices, blank=True)
  </code></pre>
  <p>I have more than 100000 devices and 100 groups. The devices can have multiple groups. I want to fetch the group_ids each device is having. I tried to loop through all the devices and fetch the group column. But it is taking too much time. Is there any pythonic way to solve this?</p>