Hi -

I'm pretty new to Django and I'm trying to do something that's
probably pretty easy, but getting it to happen is eluding me. Here's a
simplified version of what I want to do:

class A(models.Model):
  name = models.CharField(max_length = 10)

class B(models.Model):
  info = models.CharField(max_length = 10)
  a = models.ForeignKey(A)

class C(models.Model):
  stuff = models.CharField(max_length = 10)
  b = models.ForeignKey(B)

A is one-to-many to B and B is one-to-many to C.

If I know which A I'm interested in [eg, a_instance = A.objects.get(pk
= 1)], is there a way to get all the instances of C that are related
to a_instance in one step?

I know how to get all the B's related to my a_instance and then I can
loop through those to get all their C instances, but that's really
slow. Reading the docs seems to imply I can do this in one step, but
I'm having issues figuring out how it's actually done.

TIA,
- Craig

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to