title: Django select all models with foreign key
body: <p>In A Django web app I have defined a model named Server</p>
  
  <pre><code>class Server(models.model):
  </code></pre>
  
  <p>and a bunch of models that use this model as a foreign key</p>
  
  <pre><code>class ServerInfo(models.Model):
      server = models.ForeignKey(server, null=True)
  class ServerDNSRecord(models.Model):
      server = models.ForeignKey(server, null=True)
  ...etc
  </code></pre>
  
  <p>Now what I have an API call that returns a server with all of its attached info. Currently I am just doing a for loop for each server and searching each info table with the name of the server. The problem is sometimes I need to make an API call that returns ALL of the servers and their info. </p>
  
  <p>This creates a huge amount of SQL Queries to the database, and the response time on this call is usually greater than 5 seconds, which is unacceptable. </p>
  
  <p>Is there any easy way to do some sort of join or foreign key search to decrease the amount of database calls to speed things up?</p>