Suppose I have the following 2 Classes  in models.

class Student_Info(models.Model):
  Roll_No = models.IntegerField(primary_key=True)
  E_mail = models.EmailField(max_length=30)
  
class Academics(models.Model):
  Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No')
  GPA = models.IntegerField()
  Subject_Code= models.IntegerField(primary_key=True)
  
Now How would i get an out put giving me the following columns
Roll_No,GPA and Subject_Code

In sql its going to be something like this
select Roll_No,GPA,Subject_Code
from
      Student_Info  
inner join 
      Academics   on  Student_Info.Roll_No=Academics.Roll_No      


Going through the Django Book the Models section covers querying from a single 
table such as 
>>> from xxxx.models import Student_Info
>>> Student_list = Student_Info.objects.all()
This only queries a single table I want to know how we could write join table 
queries in django
Any help or suggestions  would be appreciated..Thanks



                                          

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to