def natural_pk_mti_test(format, self):
 child_1 = Child.objects.create(parent_data='1', child_data='1')
 child_2 = Child.objects.create(parent_data='2', child_data='2')
 string_data = serializers.serialize(format, [child_1.parent_ptr, child_2.parent_ptr, child_2, child_1], use_natural_foreign_keys=True, use_natural_primary_keys=True)
 child_1.delete()
 child_2.delete()
 for obj in serializers.deserialize(format, string_data):
  obj.save()
 children = Child.objects.all()
 self.assertEqual(len(children), 2)
 for child in children:
  self.assertEqual(child.child_data, child.parent_data)

def natural_pk_mti_test ( format , self ) : child_1 = Child . objects . create ( parent_data = '1' , child_data = '1' ) child_2 = Child . objects . create ( parent_data = '2' , child_data = '2' ) string_data = serializers . serialize ( format , [ child_1 . parent_ptr , child_2 . parent_ptr , child_2 , child_1 ] , use_natural_foreign_keys = True , use_natural_primary_keys = True ) child_1 . delete ( ) child_2 . delete ( ) for obj in serializers . deserialize ( format , string_data ) : obj . save ( ) children = Child . objects . all ( ) self . assertEqual ( len ( children ) , 2 ) for child in children : self . assertEqual ( child . child_data , child . parent_data )
if serializing objects in a multi-table inheritance relationship using natural primary keys .