Changes between Initial Version and Version 1 of Ticket #13741


Ignore:
Timestamp:
Jun 11, 2010, 10:09:49 AM (14 years ago)
Author:
Karen Tracey
Comment:

Fixed description formatting. PLEASE use WikiFormatting and preview before submitting.

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 
     1It seems that you can't use a !GenericForeignKey across multiple databases. My model is as follows:
     2{{{
    33class Item(Model):
    44    content_type = models.ForeignKey(ContentType)
     
    66    content_object = generic.GenericForeignKey()
    77    # Other model fields, irrelevant to this example.
    8 
     8}}}
    99From my tests, the following two scenarios happen:
    1010
    11 Scenario 1: I use the content_object approach, which uses the actual GenericForeignKey field to handle the data.
     11Scenario 1: I use the content_object approach, which uses the actual !GenericForeignKey field to handle the data.
    1212
    1313# Accessory is from a secondary database. I use routers to select it from the second database.
     14{{{
    1415>>> a = Accessory.objects.get(pk=3)
    1516>>> a
     
    2223>>> item.object_id
    23243L # This is correct
    24 
     25}}}
    2526So 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.
    2627
    2728Scenario 2: I don't use content_object and set the id/type manually.
    28 
     29{{{
    2930>>> ctype = ContentType.objects.get_for_model(Accessory)
    3031>>> fi = Item.objects.create(object_id=a.pk, content_type=ctype, title="Some real item.")
     
    3637    obj.save(force_insert=True, using=self.db)
    3738TypeError: save() got an unexpected keyword argument 'using'
    38 
     39}}}
    3940So 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.
Back to Top