summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-01-31 13:43:05 -0500
committerTim Graham <timograham@gmail.com>2018-02-01 08:56:52 -0500
commit1c9233b1b9f903e4e2cb20a724e8c22aee4aacb2 (patch)
treef059dc4100e46c9d29ccee0647cca59edc82faa0 /tests
parenta0c2e3fde75f984ab2ead30e7004cc7ab38e30a8 (diff)
[1.11.x] Fixed #29094 -- Fixed crash when entering an invalid uuid in ModelAdmin.raw_id_fields.
Regression in 2f9861d823620da7ecb291a8f005f53da12b1e89. Thanks Carel Burger for the report and fix. Backport of docs552abffab16cbdff571486b683e7e7ef12e46066 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_widgets/models.py3
-rw-r--r--tests/admin_widgets/tests.py8
2 files changed, 10 insertions, 1 deletions
diff --git a/tests/admin_widgets/models.py b/tests/admin_widgets/models.py
index 274c36e15e..4c6c10000a 100644
--- a/tests/admin_widgets/models.py
+++ b/tests/admin_widgets/models.py
@@ -1,5 +1,7 @@
from __future__ import unicode_literals
+import uuid
+
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@@ -99,6 +101,7 @@ class CarTire(models.Model):
class Honeycomb(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
location = models.CharField(max_length=20)
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 2e2bdb0b52..4d78d5fd5b 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -17,7 +17,7 @@ from django.contrib.admin.tests import AdminSeleniumTestCase
from django.contrib.auth.models import User
from django.core.files.storage import default_storage
from django.core.files.uploadedfile import SimpleUploadedFile
-from django.db.models import CharField, DateField, DateTimeField
+from django.db.models import CharField, DateField, DateTimeField, UUIDField
from django.test import SimpleTestCase, TestCase, override_settings
from django.urls import reverse
from django.utils import six, translation
@@ -251,6 +251,12 @@ class AdminForeignKeyRawIdWidget(TestDataMixin, TestCase):
lookup2 = widgets.url_params_from_lookup_dict({'myfield': my_callable()})
self.assertEqual(lookup1, lookup2)
+ def test_label_and_url_for_value_invalid_uuid(self):
+ field = Bee._meta.get_field('honeycomb')
+ self.assertIsInstance(field.target_field, UUIDField)
+ widget = widgets.ForeignKeyRawIdWidget(field.remote_field, admin.site)
+ self.assertEqual(widget.label_and_url_for_value('invalid-uuid'), ('', ''))
+
class FilteredSelectMultipleWidgetTest(SimpleTestCase):
def test_render(self):