Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
Showing with 8 additions and 0 deletions.
  1. +8 −0 genericm2m/genericm2m_tests/tests.py
8 genericm2m/genericm2m_tests/tests.py
View
@@ -334,6 +334,8 @@ def test_custom_model_using_gfks(self):
self.note_a.related.connect(self.pizza)
self.note_a.related.connect(self.note_b)
+ self.pizza.related.connect(self.note_b)
+
# create some notes with custom attributes
self.note_b.related.connect(self.cereal, alias='cereal note', description='lucky charms!')
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):
(self.note_b, self.milk),
))
+ related_to = self.note_b.related.related_to()
+ # note that pizza does not show up here even though it is related to note b
+ # this is because that relationship was stored in a different table (RelatedObject)
+ # as opposed to AnotherRelatedObject
+ self.assertEqual(related_to.generic_objects(), [self.note_a])
+
cereal_rel, milk_rel = related_b
# check that the custom attributes were saved correctly
Please sign in to comment.
Something went wrong with that request. Please try again.