Maxim Sukharev committed 9a6b914

test and docs for get_subclass

  • Participants
  • Parent commits 7d2fae4

Comments (0)

Files changed (2)

     nearby_places = Place.objects.select_subclasses("restaurant")
     # restaurants will be Restaurant instances, bars will still be Place instances
+Also it provides syntax sugar for `get()` method::
+    place = Place.objects.get_subclass(id=some_id)
+    # "place" will automatically be an instance of Place, Restaurant, or Bar
 If you don't explicitly call ``select_subclasses()``, an ``InheritanceManager``
 behaves identically to a normal ``Manager``; so it's safe to use as your
 default manager for the model.


+        def test_get_subclass(self):
+            self.assertEquals(
+                self.get_manager().get_subclass(,
+                self.child1)
     class InheritanceManagerRelatedTests(InheritanceManagerTests):
         def setUp(self):