mirror of
https://github.com/django/django.git
synced 2025-08-31 15:57:45 +00:00
Fixed #27850 -- Made RelatedFieldWidgetWrapper call render() of the wrapped widget.
This commit is contained in:
parent
c743af82cf
commit
fb7e0e01af
4 changed files with 27 additions and 17 deletions
|
@ -596,6 +596,7 @@ class ManyToManyRawIdWidgetTest(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
||||
class RelatedFieldWidgetWrapperTests(SimpleTestCase):
|
||||
def test_no_can_add_related(self):
|
||||
rel = Individual._meta.get_field('parent').remote_field
|
||||
|
@ -630,6 +631,21 @@ class RelatedFieldWidgetWrapperTests(SimpleTestCase):
|
|||
self.assertTrue(wrapper.can_change_related)
|
||||
self.assertFalse(wrapper.can_delete_related)
|
||||
|
||||
def test_custom_widget_render(self):
|
||||
class CustomWidget(forms.Select):
|
||||
def render(self, *args, **kwargs):
|
||||
return 'custom render output'
|
||||
rel = Album._meta.get_field('band').remote_field
|
||||
widget = CustomWidget()
|
||||
wrapper = widgets.RelatedFieldWidgetWrapper(
|
||||
widget, rel, widget_admin_site,
|
||||
can_add_related=True,
|
||||
can_change_related=True,
|
||||
can_delete_related=True,
|
||||
)
|
||||
output = wrapper.render('name', 'value')
|
||||
self.assertIn('custom render output', output)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
||||
class AdminWidgetSeleniumTestCase(AdminSeleniumTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue