Changes between Initial Version and Version 1 of Ticket #13741
- Timestamp:
- Jun 11, 2010, 10:09:49 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #13741 – Description
initial v1 1 It seems that you can't use a GenericForeignKey across multiple databases. My model is as follows:2 1 It seems that you can't use a !GenericForeignKey across multiple databases. My model is as follows: 2 {{{ 3 3 class Item(Model): 4 4 content_type = models.ForeignKey(ContentType) … … 6 6 content_object = generic.GenericForeignKey() 7 7 # Other model fields, irrelevant to this example. 8 8 }}} 9 9 From my tests, the following two scenarios happen: 10 10 11 Scenario 1: I use the content_object approach, which uses the actual GenericForeignKey field to handle the data.11 Scenario 1: I use the content_object approach, which uses the actual !GenericForeignKey field to handle the data. 12 12 13 13 # Accessory is from a secondary database. I use routers to select it from the second database. 14 {{{ 14 15 >>> a = Accessory.objects.get(pk=3) 15 16 >>> a … … 22 23 >>> item.object_id 23 24 3L # This is correct 24 25 }}} 25 26 So it looks like it doesn't pick the right table to work with. It picks another model from the primary database, not going for the second database. 26 27 27 28 Scenario 2: I don't use content_object and set the id/type manually. 28 29 {{{ 29 30 >>> ctype = ContentType.objects.get_for_model(Accessory) 30 31 >>> fi = Item.objects.create(object_id=a.pk, content_type=ctype, title="Some real item.") … … 36 37 obj.save(force_insert=True, using=self.db) 37 38 TypeError: save() got an unexpected keyword argument 'using' 38 39 }}} 39 40 So at this point I am at a loss. I asked around and no one knows if this is a bug or if I'm doing something wrong, so I am assuming it's a bug.