1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26449 -- Merged admin's FORMFIELD_FOR_DBFIELD_DEFAULTS with formfield_overrides.

Useful for overriding the DateTimeField widget.
This commit is contained in:
marysia
2016-05-03 14:33:18 +02:00
committed by Tim Graham
parent aec4f97555
commit b9290b1d49
2 changed files with 28 additions and 3 deletions

View File

@@ -117,8 +117,11 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
return self.checks_class().check(self, **kwargs)
def __init__(self):
overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()
overrides.update(self.formfield_overrides)
# Merge FORMFIELD_FOR_DBFIELD_DEFAULTS with the formfield_overrides
# rather than simply overwriting.
overrides = copy.deepcopy(FORMFIELD_FOR_DBFIELD_DEFAULTS)
for k, v in self.formfield_overrides.items():
overrides.setdefault(k, {}).update(v)
self.formfield_overrides = overrides
def formfield_for_dbfield(self, db_field, request, **kwargs):