Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Fixed #19303 -- Fixed ModelAdmin.formfield_overrides on field…

…s with choices"

This reverts commit 9d1987d.
  • Loading branch information...
commit 5046c110cfbf5e867fec47c8c68677a76c9e1b68 1 parent 5a504a5
@timgraham timgraham authored
Showing with 0 additions and 21 deletions.
  1. +0 −4 django/contrib/admin/options.py
  2. +0 −17 tests/admin_widgets/tests.py
View
4 django/contrib/admin/options.py
@@ -147,7 +147,6 @@ def check(cls, model, **kwargs):
return cls.checks_class().check(cls, model, **kwargs)
def __init__(self):
- self._orig_formfield_overrides = self.formfield_overrides
overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()
overrides.update(self.formfield_overrides)
self.formfield_overrides = overrides
@@ -164,9 +163,6 @@ def formfield_for_dbfield(self, db_field, **kwargs):
# If the field specifies choices, we don't need to look for special
# admin widgets - we just need to use a select widget of some kind.
if db_field.choices:
- # see #19303 for an explanation of self._orig_formfield_overrides
- if db_field.__class__ in self._orig_formfield_overrides:
- kwargs = dict(self._orig_formfield_overrides[db_field.__class__], **kwargs)
return self.formfield_for_choice_field(db_field, request, **kwargs)
# ForeignKey or ManyToManyFields
View
17 tests/admin_widgets/tests.py
@@ -142,23 +142,6 @@ class BandAdmin(admin.ModelAdmin):
self.assertEqual(f2.widget.attrs['maxlength'], '20')
self.assertEqual(f2.widget.attrs['size'], '10')
- def testFormfieldOverridesWidgetInstancesForFieldsWithChoices(self):
- """
- Test that widget is actually overridden for fields with choices.
- (#194303)
- """
- class MemberAdmin(admin.ModelAdmin):
- formfield_overrides = {
- CharField: {'widget': forms.TextInput}
- }
- ma = MemberAdmin(models.Member, admin.site)
- name_field = models.Member._meta.get_field('name')
- gender_field = models.Member._meta.get_field('gender')
- name = ma.formfield_for_dbfield(name_field, request=None)
- gender = ma.formfield_for_dbfield(gender_field, request=None)
- self.assertIsInstance(name.widget, forms.TextInput)
- self.assertIsInstance(gender.widget, forms.TextInput)
-
def testFieldWithChoices(self):
self.assertFormfield(models.Member, 'gender', forms.Select)
Please sign in to comment.
Something went wrong with that request. Please try again.