I have some models that (simplified) look like the following. class Answer(models.Model): id = models.CharField(max_length=32, primary_key=True) text = models.TextField(blank=False) question = models.ForeignKey(Question) candidate = models.ForeignKey(Candidate)
class Question(models.Model): id = models.CharField(max_length=32, primary_key=True) text = models.TextField(blank=False) class Candidate(models.Model): id = models.CharField(max_length=32, primary_key=True) name = models.CharField(max_length=32, blank=False) class Race(models.Model): id = models.CharField(max_length=32, primary_key=True) name = models.CharField(max_length=128, blank=False) questions = models.ManyToManyField(Question) candidates = models.ManyToManyField(Candidate) So, a Race has Candidates and Questions, and a Candidate has Answers. Each answer is associated with a Question and a Candidate. Displaying the question associated with an answer is easy: # context variable in view answers = Answer.objects.filter(candidate=candidate) # template code <table> {% for answer in answers %} <tr> <td>{{answer.question.text}}</td> <td>{{answer.text}}</td> </tr> {% endfor %} </table> >From the point of view of the Candidate, I need to display all the questions, including the ones without Answers. I know how to to do this using raw sql and an outer join. How to do it in the orm? Thanks in advance for any ideas. --Jeff -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.