[1.10.x] Fixed #27905 -- Added RelatedFieldWidgetWrapper.value_omitted_from_data().
Backport of fd75c8f2b7
from master
This commit is contained in:
parent
bae7955955
commit
c4b8c46345
|
@ -337,6 +337,9 @@ class RelatedFieldWidgetWrapper(forms.Widget):
|
|||
def value_from_datadict(self, data, files, name):
|
||||
return self.widget.value_from_datadict(data, files, name)
|
||||
|
||||
def value_omitted_from_data(self, data, files, name):
|
||||
return self.widget.value_omitted_from_data(data, files, name)
|
||||
|
||||
def id_for_label(self, id_):
|
||||
return self.widget.id_for_label(id_)
|
||||
|
||||
|
|
|
@ -9,4 +9,5 @@ Django 1.10.7 fixes several bugs in 1.10.6.
|
|||
Bugfixes
|
||||
========
|
||||
|
||||
* ...
|
||||
* Made admin's ``RelatedFieldWidgetWrapper`` use the wrapped widget's
|
||||
``value_omitted_from_data()`` method (:ticket:`27905`).
|
||||
|
|
|
@ -631,6 +631,15 @@ class RelatedFieldWidgetWrapperTests(SimpleTestCase):
|
|||
self.assertTrue(wrapper.can_change_related)
|
||||
self.assertFalse(wrapper.can_delete_related)
|
||||
|
||||
def test_widget_delegates_value_omitted_from_data(self):
|
||||
class CustomWidget(forms.Select):
|
||||
def value_omitted_from_data(self, data, files, name):
|
||||
return False
|
||||
rel = models.Album._meta.get_field('band').remote_field
|
||||
widget = CustomWidget()
|
||||
wrapper = widgets.RelatedFieldWidgetWrapper(widget, rel, widget_admin_site)
|
||||
self.assertIs(wrapper.value_omitted_from_data({}, {}, 'band'), False)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
||||
class AdminWidgetSeleniumTestCase(AdminSeleniumTestCase):
|
||||
|
|
Loading…
Reference in New Issue