Hi All,

Just curious, does the Django Database API support nested  
relationships more than one level deep? It's starting to look like it  
doesn't... for example, let's say I have three tables: Contest,  
Categories, and Finalists; related as such: Contest, Category foreign  
keys to Contest, Finalist foreign keys to Category (a nested  
relationship).

Let's continue with the example of a "talent contest":
A (Contest) contains the actual contest details (date and time it  
occurred, judges, a description, location, etc.)
B (Category) contains the contest's associated categories (juggling,  
music, tight-rope-walking, etc.)
C (Finalist) contains the finalists for each category (1st place, 2nd  
place, 3rd place).

As you can see, table C is related to A, but only indirectly via B  
(hence the nested relation). Here is an extremely simplified model  
for the purpose of illustration:

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

     def __str__(self):
         return "Contest: %s" % self.name

     class Admin:
         pass

class Category(models.Model):
     name = models.CharField(maxlength=100)
     contest = models.ForeignKey(Contest)

     def __str__(self):
         return self.name

class Finalist(models.Model):
     name = models.CharField(maxlength=100)
     category = models.ForeignKey(Category)

     def __str__(self):
         return self.name

In the console, if I populate the Contest, the instance produces a  
"category_set" method/property (as expected and documented). However,  
if you "dir(c.category_set)" there is no "finalist_set" method/ 
property in the category_set's namespace... So, am I correct in  
surmising that the current implementation of the ORM will not  
currently work with this type of DB model (2 level indirection)? Is  
there a workaround? Any thoughts or suggestions are most welcome.

Hopefully all of this makes sense... thanks in advance,
-D






--~--~---------~--~----~------------~-------~--~----~
 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