Ticket #29094: 29094.patch

File 29094.patch, 857 bytes (added by Carel Burger, 7 years ago)
  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index 40afe0773f..91795d4ce4 100644
    a b import json  
    66
    77from django import forms
    88from django.conf import settings
     9from django.core.exceptions import ValidationError
    910from django.db.models.deletion import CASCADE
    1011from django.urls import reverse
    1112from django.urls.exceptions import NoReverseMatch
    class ForeignKeyRawIdWidget(forms.TextInput):  
    183184        key = self.rel.get_related_field().name
    184185        try:
    185186            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):
    187188            return '', ''
    188189
    189190        try:
Back to Top