id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 9422 Incorrect handling of foreign keys by serializers Dave Hall "When a foreign key points to a remote object via a non-primary key field, the Python serializer and XML serializer classes can sometimes handle this incorrectly. This occurs when the primary key of the related object is a OneToOneField, as is the case for model inheritance. In this case, the serializer will store the __unicode__ version of the primary key, rather than the primary key itself. As an example: {{{ class Foo(models.Model): pass class Bar(Foo): name = models.CharField(max_length=244) slug = models.SlugField(unique=True) def __unicode__(self): return self.name class Wibble(models.Model): bar = models.ForeignKey(Bar, to_field=""slug"") }}} when a Wibble instance is serialized, the value of the 'bar' property will be serialized as the result of calling __unicode__ on the referenced Bar. This problem can be resolved with the attached patch." Bug closed Core (Serialization) 1.0 Normal fixed david@… Dave Hall Accepted 1 0 1 1 0 0