diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-14 19:37:12 +0000 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-20 11:46:57 +0000 |
| commit | c54d73ae01cd787315ba030da17e266c49f386b3 (patch) | |
| tree | ca3f1ddf19fffe2be65b16c81853176571758f5d /tests/model_fields | |
| parent | 82f39bfb1ac9a4e9c67cb26259bc689947f4c6d0 (diff) | |
[1.8.x] Fixed #24343 -- Ensure db converters are used for foreign keys.
Joint effort between myself, Josh, Anssi and Shai.
Conflicts:
django/db/models/query.py
tests/model_fields/models.py
Backport of 4755f8fc25331c739a6f932cc8aba0cc9e62e352 from master.
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/models.py | 4 | ||||
| -rw-r--r-- | tests/model_fields/test_uuid.py | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py index 5f580624ba..3d25c89607 100644 --- a/tests/model_fields/models.py +++ b/tests/model_fields/models.py @@ -369,3 +369,7 @@ class NullableUUIDModel(models.Model): class PrimaryKeyUUIDModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4) + + +class RelatedToUUIDModel(models.Model): + uuid_fk = models.ForeignKey('PrimaryKeyUUIDModel') diff --git a/tests/model_fields/test_uuid.py b/tests/model_fields/test_uuid.py index f06f4d02a7..28e11914a1 100644 --- a/tests/model_fields/test_uuid.py +++ b/tests/model_fields/test_uuid.py @@ -5,7 +5,9 @@ from django.core import exceptions, serializers from django.db import models from django.test import TestCase -from .models import NullableUUIDModel, PrimaryKeyUUIDModel, UUIDModel +from .models import ( + NullableUUIDModel, PrimaryKeyUUIDModel, RelatedToUUIDModel, UUIDModel, +) class TestSaveLoad(TestCase): @@ -121,3 +123,9 @@ class TestAsPrimaryKey(TestCase): self.assertTrue(u1_found) self.assertTrue(u2_found) self.assertEqual(PrimaryKeyUUIDModel.objects.count(), 2) + + def test_underlying_field(self): + pk_model = PrimaryKeyUUIDModel.objects.create() + RelatedToUUIDModel.objects.create(uuid_fk=pk_model) + related = RelatedToUUIDModel.objects.get() + self.assertEqual(related.uuid_fk.pk, related.uuid_fk_id) |
