diff options
| author | Andriy Sokolovskiy <me@asokolovskiy.com> | 2015-02-13 16:21:33 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-13 12:45:35 -0500 |
| commit | 136edac8974ff0b570ce0a3e66e7aadf542225f0 (patch) | |
| tree | 309b219e8ab0cd43d0f2449bac653cce778c25ba /tests | |
| parent | 8277f5d7d0849943a2b501d256927a049adda499 (diff) | |
[1.8.x] Fixed #24320 - Used field.value_to_string() in serialization of foreign key.
This fixes serialization of a ForeignKey to a UUIDField as the
test indicates.
Backport of 5c995dcfc251b55284e1ef16545acd2acad6be04 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/serializers_regress/models.py | 4 | ||||
| -rw-r--r-- | tests/serializers_regress/tests.py | 23 |
2 files changed, 17 insertions, 10 deletions
diff --git a/tests/serializers_regress/models.py b/tests/serializers_regress/models.py index b7c4575c6d..b7f9c5f5fa 100644 --- a/tests/serializers_regress/models.py +++ b/tests/serializers_regress/models.py @@ -284,6 +284,10 @@ class UUIDData(models.Model): data = models.UUIDField(primary_key=True) +class FKToUUID(models.Model): + data = models.ForeignKey(UUIDData) + + class ComplexModel(models.Model): field1 = models.CharField(max_length=10) field2 = models.CharField(max_length=10) diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py index 71a19f7381..537965520b 100644 --- a/tests/serializers_regress/tests.py +++ b/tests/serializers_regress/tests.py @@ -29,15 +29,16 @@ from .models import ( BooleanData, BooleanPKData, CharData, CharPKData, ComplexModel, DateData, DateTimeData, DecimalData, DecimalPKData, EmailData, EmailPKData, ExplicitInheritBaseModel, FileData, FilePathData, FilePathPKData, FKData, - FKDataNaturalKey, FKDataToField, FKDataToO2O, FKSelfData, FloatData, - FloatPKData, GenericData, GenericIPAddressData, GenericIPAddressPKData, - InheritAbstractModel, InheritBaseModel, IntegerData, IntegerPKData, - Intermediate, IPAddressData, IPAddressPKData, LengthModel, M2MData, - M2MIntermediateData, M2MSelfData, ModifyingSaveData, NaturalKeyAnchor, - NullBooleanData, O2OData, PositiveIntegerData, PositiveIntegerPKData, - PositiveSmallIntegerData, PositiveSmallIntegerPKData, ProxyBaseModel, - ProxyProxyBaseModel, SlugData, SlugPKData, SmallData, SmallPKData, Tag, - TextData, TimeData, UniqueAnchor, UUIDData, + FKDataNaturalKey, FKDataToField, FKDataToO2O, FKSelfData, FKToUUID, + FloatData, FloatPKData, GenericData, GenericIPAddressData, + GenericIPAddressPKData, InheritAbstractModel, InheritBaseModel, + IntegerData, IntegerPKData, Intermediate, IPAddressData, IPAddressPKData, + LengthModel, M2MData, M2MIntermediateData, M2MSelfData, ModifyingSaveData, + NaturalKeyAnchor, NullBooleanData, O2OData, PositiveIntegerData, + PositiveIntegerPKData, PositiveSmallIntegerData, + PositiveSmallIntegerPKData, ProxyBaseModel, ProxyProxyBaseModel, SlugData, + SlugPKData, SmallData, SmallPKData, Tag, TextData, TimeData, UniqueAnchor, + UUIDData, ) try: @@ -203,6 +204,7 @@ im_obj = (im_create, im_compare) o2o_obj = (o2o_create, o2o_compare) pk_obj = (pk_create, pk_compare) inherited_obj = (inherited_create, inherited_compare) +uuid_obj = uuid.uuid4() test_data = [ # Format: (data type, PK value, Model Class, data) @@ -361,7 +363,8 @@ The end."""), # The end."""), # (pk_obj, 770, TimePKData, datetime.time(10, 42, 37)), # (pk_obj, 790, XMLPKData, "<foo></foo>"), - (pk_obj, 791, UUIDData, uuid.uuid4()), + (pk_obj, 791, UUIDData, uuid_obj), + (fk_obj, 792, FKToUUID, uuid_obj), (data_obj, 800, AutoNowDateTimeData, datetime.datetime(2006, 6, 16, 10, 42, 37)), (data_obj, 810, ModifyingSaveData, 42), |
