Hello!

I'm new to Django, so please forgive my newbness :)

The following is my model:

class City(models.Model):
    name = models.CharField(maxlength=100)

class Person(models.Model)
    name = models.CharField(maxlength=100)
    city = models.ForeignKey(City)

class Book(models.Model)
    name = models.CharField(maxlength=100)
    owner = models.ForeignKey(Person)

Is it possible to formulate a query to get an object that you can
iterate over like this:

for c in cities:
    for p in c.people:
        for b in p.books:
            print ",".join([c.name, p.name, b.name])

If not, how would one typically do this?
--~--~---------~--~----~------------~-------~--~----~
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