title: Avoiding multiple queries to display model data on Django admin
body: <p>I am using Django amdin for one of my data models. I want to display customized values on admin UI for each model.
  On db, the result of a single query runs as multiple queries on django admin, one for each row 
  I am trying to avoid that.</p>
  
  <p>Here are my models:</p>
  
  <pre><code>class words(models.Model):
      word_id=models.AutoField(primary_key=True)
      word=models.CharField(max_length=200,unique=True)
      def __unicode__(self):
          return '%s - %s' % (self.word,self.word_id)
  
  class meanings(models.Model):
      id=models.AutoField(primary_key=True)
      word_id=models.ForeignKey(words,on_delete=models.CASCADE,db_column='word_id')
      meaning=models.CharField(max_length=200)
      def __unicode__(self):
          return '%s  %s  %d ' % ( self.spelling_id.spelling,self.meaning,self.id)
  </code></pre>
  
  <p>For the second model, while loading the page, for each row I saw there are  2 queries running one on words table and other on meanings table. (from debug toolbar)</p>
  
  <p>I tried avoiding that by using the below option.</p>
  
  <p>models.py:</p>
  
  <pre><code>class meanings(models.Model):
      meaning_id=models.AutoField(primary_key=True)
      word_id=models.ForeignKey(words,on_delete=models.CASCADE,db_column='word_id')
      meaning=models.CharField(max_length=200)
  </code></pre>
  
  <p>admin.py:</p>
  
  <pre><code>def modified_output(self):
          cursor = connection.cursor()
          cursor.execute("select word,meaning,id from meanings a,words b where a.word_id=b.word_id and meaning_id= "+str(self.id))
          row = dictfetchall(cursor)
          a=unicode(row[0]['word'])
          b=unicode(row[0]['meaning'])
          d=(row[0]['id'])
          return '%s  %s  %d ' % ( a,b,d)
  
  
  meanings.add_to_class("__str__", modified_output)
  </code></pre>
  
  <p>Now for each row there is only 1 query running. But as the dependency on models have more than 2 tables in join of a query, it will still consume time. So my question is instead of running 1 query for each row, can we have the query result displayed directly for each page. </p>
  
  <p>for example result of the following query on a page:</p>
  
  <pre><code>select * from table ;
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>select * from table when id=1;
  select * from table when id=2;
  .
  .
  .
  </code></pre>
  
  <p>Any help is greatly appreciated.Thanks</p>