title: Get multiple objects in one query in Django
body: <p>I have 3 models:</p>
  <pre><code>class Ticket(models.Model):
      id = models.CharField(primary_key=True, max_length=20, null=False)
      title = models.CharField(max_length=255, blank=False, null=True)
      description = models.TextField(blank=False, null=True)
  
  class Attachment(models.Model):
      ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
      file = models.FileField(blank=True, null=True, upload_to='attachments/')
  
  class Comment(models.Model):
      ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
      comment = models.TextField(null=False)
  </code></pre>
  <p>In my views.py file in want to process all of them, so in order to get them I perform 3 queries:</p>
  <pre><code>tickets = Ticket.objects.filter(id=ticket_id)
  attachments = Attachment.objects.filter(ticket=ticket_id)
  comments = Comment.objects.filter(ticket=ticket.id)
  </code></pre>
  <p>I want to hit database just once, so my question is how can I get them in one query? I have read about <a href="https://docs.djangoproject.com/en/3.1/ref/models/querysets/#django.db.models.query.QuerySet.select_related" rel="nofollow noreferrer">select_related()</a> method, but <strong>Attachment</strong> and <strong>Comment</strong> models are not related directly to each other, so I can't start query from any of them. From the other hand <strong>Ticket</strong> model doesn't have fields like <strong>attachment</strong> or <strong>comment</strong> so I can't start query from it.</p>