Ticket #29901: mypatch.diff

File mypatch.diff, 1.7 KB (added by Javier Matos Odut, 6 years ago)

Patch to fix the issue

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 43a90b302c..241d22e82a 100644
    a b class BaseModelAdmin(metaclass=forms.MediaDefiningClass):  
    224224        """
    225225        db = kwargs.get('using')
    226226
    227         if db_field.name in self.get_autocomplete_fields(request):
    228             kwargs['widget'] = AutocompleteSelect(db_field.remote_field, self.admin_site, using=db)
    229         elif db_field.name in self.raw_id_fields:
    230             kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
    231         elif db_field.name in self.radio_fields:
    232             kwargs['widget'] = widgets.AdminRadioSelect(attrs={
    233                 'class': get_ul_class(self.radio_fields[db_field.name]),
    234             })
    235             kwargs['empty_label'] = _('None') if db_field.blank else None
     227        if 'widget' not in kwargs:
     228            if db_field.name in self.get_autocomplete_fields(request):
     229                kwargs['widget'] = AutocompleteSelect(db_field.remote_field, self.admin_site, using=db)
     230            elif db_field.name in self.raw_id_fields:
     231                kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
     232            elif db_field.name in self.radio_fields:
     233                kwargs['widget'] = widgets.AdminRadioSelect(attrs={
     234                    'class': get_ul_class(self.radio_fields[db_field.name]),
     235                })
     236                kwargs['empty_label'] = _('None') if db_field.blank else None
    236237
    237238        if 'queryset' not in kwargs:
    238239            queryset = self.get_field_queryset(db, db_field, request)
Back to Top