I have a strange issue where prefetch_related sometimes fails to populate related objects when using Proxy models. I believe it is a bug, but I'd like some second opinions on what might be going on.
*Here is my example filter:* my_filter = Activity.objects.all().prefetch_related("recording_set") If the first item in the queryset is of a certain proxy model (in the example below, "sms"), no prefetched objects are populated. In other words, if the first item has "activity=sms" (and not "activity=call") then no "recordings" are populated in ANY of the queryset items returned. *Here are my example models:* class Activity(models.Model): activity = models.CharField(max_length=20, choices=ACTIVITY_CHOICES, default='call') class CallManager(models.Manager): def get_queryset(self): return super(CallManager, self).get_queryset().filter(activity='call') class Call(Activity): def __init__(self, *args, **kwargs): self._meta.get_field('activity').default = "call" super(Call, self).__init__(*args, **kwargs) class Meta: proxy = True objects = CallManager() class SmsManager(models.Manager): def get_queryset(self): return super(SmsManager, self).get_queryset().filter(activity='sms') class Sms(Activity): def __init__(self, *args, **kwargs): self._meta.get_field('activity').default = "sms" super(Sms, self).__init__(*args, **kwargs) class Meta: proxy = True objects = SmsManager() class Recording(models.Model): sms = models.ForeignKey("Sms", null=True, blank=True) call = models.ForeignKey("Call", null=True, blank=True) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/47f8b0a7-27bd-45d0-80fc-897953b9ff73%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.