Hey, I have three models but I can only handle the relationship between two at any one time.
Basically I have a page that needs to show a threads the current user's friends are currently participating in. I.E. something like this: Thread: ABC Participating: Friend 1 Thread: XYZ Participating: Friend 1, Friend 2, Friend 3 Here are my models (both of which refer to the default Auth model): ---------------------------------- File: /people/models.py ---------------------------------- class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) friends = models.ManyToManyField(User, blank=True, related_name='friend_set') ---------------------------------- File: /thread/models.py ---------------------------------- class Thread(models.Model): title = models.CharField(maxlength=200) users = models.ManyToManyField(User, related_name='users') ---------------------------------- Now here is my view file: ---------------------------------- File: /people/views.py ---------------------------------- def index(request): # get profile profile = get_object_or_404(UserProfile, user__id__exact=request.user.id) # get friends for user friends = profile.friends.all() # get threads for friends ??????????? ---------------------------------- As you can see, I don't know what to do now I need to get the threads for each individual user. I don't need to group them in a special way, I just want to print the threads my friends are currently participating in an alphabetical list. I did wonder if I should just edit the UserProfile model like this? ---------------------------------- File: /people/models.py ---------------------------------- class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) friends = models.ManyToManyField(User, blank=True, related_name='friend_set') threads = models.ManyToManyField(Thread, blank=True, related_name='thread_set') ---------------------------------- Any ideas on how to do this? I'm guessing it's probably fairly basic but I can't think how I would get around this at the moment (it's been a long week!) ;) Cheers, Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---