title: How to write query with in a model with foreign key relation?
body: <pre><code>class Categorie(models.Model):
      name = models.CharField(max_length=200)
      description = models.TextField(max_length=2000)
      status = models.BooleanField(default=True)
      added_date = models.DateTimeField(auto_now_add=True)
  
      def __unicode__(self):
       return u'%s' % self.name
  
  
  class GroupQuestion(models.Model):
      category = models.ForeignKey(Categorie, related_name='%(class)s_name_related', null=True)
      name = models.CharField(max_length=200)
      added_date = models.DateTimeField(auto_now_add=True)
      status = models.BooleanField(default=True)
  
      class Meta:
          verbose_name = 'Group of Questions'
          verbose_name_plural = 'Group of Questions'
  
      def __unicode__(self):
          return u'%s' % self.name
  
  
   class Question(models.Model):
      category = models.ForeignKey(Categorie, related_name='%(class)s_name_related', null=True)
      group = models.ForeignKey(GroupQuestion, related_name='%(class)s_name_related')
      name = models.TextField(max_length=200)
      added_date = models.DateTimeField(auto_now_add=True)
      status = models.BooleanField(default=True)
      #select_choice = models.CharField(max_length=5, choices=QUESTION_CHOICES, null=True)
      positive_answer = models.PositiveIntegerField()
      negative_answer = models.PositiveIntegerField()
  
     def __unicode__(self):
         return u'%s' % self.name
  </code></pre>
  
  <p>I have these three model. When I pass category_id from my API wants to get QuestionGroups and Questions related to that group?</p>
  
  <p>Some thing like this</p>
  
  <p>"data": [
           {
              id:1
              name = ABC
              "question":[
                          {
                            "id":1
                            "name":ABC
                          }
                          {
                            "id":1
                            "name":ABC
                          }
                      ]
                  }
                 {
                    id:1
                    name = ABC
                    "question":[
                           {
                             "id":1
                             "name":ABC
                           }
                           {
                             "id":1
                             "name":ABC
                           }
                       ]
                   }
    }</p>
  
  <p>I am new in django some can help me how to write query in view and how to serialize data.       </p>