Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Illustrate when models are mixed using different related_model and the

effect on reverse queries
  • Loading branch information...
commit b3b56f78efdcff06729ca3fff64e0084ae238ccf 1 parent a6657a9
Charles Leifer authored July 12, 2012

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  genericm2m/genericm2m_tests/tests.py
8  genericm2m/genericm2m_tests/tests.py
@@ -334,6 +334,8 @@ def test_custom_model_using_gfks(self):
334 334
         self.note_a.related.connect(self.pizza)
335 335
         self.note_a.related.connect(self.note_b)
336 336
 
  337
+        self.pizza.related.connect(self.note_b)
  338
+
337 339
         # create some notes with custom attributes
338 340
         self.note_b.related.connect(self.cereal, alias='cereal note', description='lucky charms!')
339 341
         self.note_b.related.connect(self.milk, alias='milk note', description='goes good with cereal')
@@ -356,6 +358,12 @@ def test_custom_model_using_gfks(self):
356 358
             (self.note_b, self.milk),
357 359
         ))
358 360
 
  361
+        related_to = self.note_b.related.related_to()
  362
+        # note that pizza does not show up here even though it is related to note b
  363
+        # this is because that relationship was stored in a different table (RelatedObject)
  364
+        # as opposed to AnotherRelatedObject
  365
+        self.assertEqual(related_to.generic_objects(), [self.note_a])
  366
+
359 367
         cereal_rel, milk_rel = related_b
360 368
 
361 369
         # check that the custom attributes were saved correctly

0 notes on commit b3b56f7

Please sign in to comment.
Something went wrong with that request. Please try again.