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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user