diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 40afe0773f..91795d4ce4 100644
a
|
b
|
import json
|
6 | 6 | |
7 | 7 | from django import forms |
8 | 8 | from django.conf import settings |
| 9 | from django.core.exceptions import ValidationError |
9 | 10 | from django.db.models.deletion import CASCADE |
10 | 11 | from django.urls import reverse |
11 | 12 | from django.urls.exceptions import NoReverseMatch |
… |
… |
class ForeignKeyRawIdWidget(forms.TextInput):
|
183 | 184 | key = self.rel.get_related_field().name |
184 | 185 | try: |
185 | 186 | obj = self.rel.model._default_manager.using(self.db).get(**{key: value}) |
186 | | except (ValueError, self.rel.model.DoesNotExist): |
| 187 | except (ValueError, self.rel.model.DoesNotExist, ValidationError): |
187 | 188 | return '', '' |
188 | 189 | |
189 | 190 | try: |