hi i am having problem with relating objects. i have models as below

class support():
   suptype = models.CharField(maxlength=255)

class DispMaster():
    dmtype=models.ForeignKey(support)

class DataDispMaster():
    ddmmaster=models.ForeignKey(Master)

class Master():

class DataMaster():
   dmmaster = models.ForeignKey(Master)

i want to get one row from support table,
get its related entry from DispMaster table,
get multiple entries from DataDispMaster table related to DispMaster
table,
get multiple entries from Master table related to DataDispMaster
table,
finally get values from DataMaster table related to Master table

this is what i have done so far (i really don't think it is good
enough)
supid=support.objects.filter(suptype="Basic")         #this will
return one row only
dispmid=DispMaster.objects.filter(dmtype=supid[0].id)    #this also
will return only one row
mid = Master.objects.filter(datadispmaster__ddmmaster__exact =
dispmid[0].id)  #this is where i am getting problems because i will
get multiple values from here which again will be used in the next
query to get further values.

now i want values from DataMaster table respective to the values i
have got in previous table.

i have also read the discussion going at
http://groups.google.co.in/group/django-users/browse_thread/thread/91985e7ca5ad7c8c?hl=en#

i still figuring it out if django ORM support this type of query. and
if not what is the best way to overcome this problem.
one way i think is to get the dictionary for mid object
(mid.values('id'))     and convert the dictionary to list and use ORMs
IN function. but this, i dont' think, is good solution

if any body can help me to organize these queries


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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