Oops. That title should be "conditional if," of course. On Apr 19, 2:43 pm, Matt <matt.w...@gmail.com> wrote: > Hoping you all can tell me what I'm doing that's stupid here. I have > three models: > > class highschool(models.Model): > name = models.CharField(max_length=50) > address = models.CharField(max_length=60) > city = models.CharField(max_length=60) > state = models.CharField(max_length=2) > > class college(models.Model): > name = models.CharField(max_length=75) > city = models.CharField(max_length=60) > state = models.CharField(max_length=2) > conference = models.ForeignKey(conference) > URL = models.URLField(verify_exists=True, max_length=200) > > class recruit(models.Model): > name = models.CharField(max_length = 100) > ... > school = models.ForeignKey(highschool) > colleges = models.ManyToManyField(college, > related_name="collegechoices") > > What I'm trying to do is find out, for a given highschool: 1) What > schools are after their recruits and 2) how many they're after. > > So far I've tried various iterations of something like: > > collegelist = > college.current_objects.filter(collegechoices__school=highschoolid).exclude(name='Undeclared').distinct().annotate(ccount=Count('collegechoices')) > > Obviously, that doesn't work, as it counts up the total number of > collegechoices without filtering for the highschool. > > I've seen some workarounds for the conditional if, but I have to think > there's an easier way to skin this cat. Any ideas? > > -- > 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 > athttp://groups.google.com/group/django-users?hl=en.
-- 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.