title: Django - How to return all objects in a QuerySet in their subclass form, rather than their parent class form?
body: <p>I have a class <code>Set</code> with a many-to-many relationship to <code>Item</code>. I have lots of 'set' objects all containing lots of 'items'. </p>
  
  <p>However, the <code>Item</code> class has been subclassed to create <code>Article</code>, <code>Podcast</code>, <code>Video</code>, and <code>Episode</code>. Basically, everything on the database was originally an Item. If <code>my_set</code> is a <code>Set</code> instance, containing <code>Items</code> - how do I create a Queryset which returns those objects in their subclass form? Ie, rather than me getting a Queryset full of Item instances, I get a Queryset with <code>Article</code>, <code>Episode</code>, <code>Video</code>, <code>Podcast</code> instances.</p>
  
  <p>How would I get `my_set.objects.all().as_subclass()' to work?</p>
  
  <pre><code>class Item(models.Model, AdminVideoMixin):
     base_attributes = 'foo'
  
       def as_episode(self):
         return Episode.objects.get(slug=self.slug)
  
  class Video(Item): 
     class specific fields
  
  class Article(Item):
     class specific fields
  
  class Podcast(Item):
     class specific fields
  
  class Episode(Item):
     class specific fields
  
  class Set(Item):
      front_page = models.BooleanField(max_length=300, blank=False, default=False, null=False)
      items = models.ManyToManyField(Item, related_name='in_sets', through='SetMeta', max_length=5000,)
  
      def get_absolute_url(self):
          return reverse('foo')
  
      def ordered(self):
          return self.items.all().order_by('-itemOrder__order')
  
      def episodes(self):
          episode_list = []
          for each_item in self.items.all():
             episode_list.append(each_item.as_episode())
          return episode_list
  
  
      def __str__(self):
          return self.title
  
  </code></pre>
  
  <p>As you can see I tried two methods - to write a model method on Item() which returns itself as an Episode - but this only worked for single instances rather than a Queryset. As such I wrote a method on Set which can perform that method on all items within the self, but this doesn't produce a Queryset, just a list, and it feels messy?</p>