#34624: RelatedFieldWidgetWrapper links toggling isn’t working for radio widgets
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Coen van
| der Kamp
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by Thibaud Colas:
Old description:
> In the Redirects contrib module, when creating a new redirect, the first
> field is for a Site instance. This is using a radio button
> (`radio_fields` ModelAdmin definition:
> https://github.com/django/django/blob/main/django/contrib/redirects/admin.py#L10).
> This uses `RelatedFieldWidgetWrapper` – which doesn’t work for radio
> widgets. Demo:
>
> [[Image(https://code.djangoproject.com/raw-attachment/ticket/34624
> /related-links.gif)]]
>
> If we look at
> [https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js#L223-L230
> RelatedObjectLookups.js], it seems clear this code was only written to
> support `select` widgets.
>
> Tagging this `contrib.admin` because it seems to affect all usage of
> `RelatedFieldWidgetWrapper` – but as far as I can see in Django itself
> only `contrib.redirects` uses radio_fields.
>
> ---
>
> In this instance I believe a `select` widget would be a much nicer
> experience anyway, so not entirely sure whether it makes sense to change
> the widget to fix this, or update the code to support radio buttons, or
> do both.
New description:
Spotted as part of #34622. In the Redirects contrib module, when creating
a new redirect, the first field is for a Site instance. This is using a
radio button (`radio_fields` ModelAdmin definition:
https://github.com/django/django/blob/main/django/contrib/redirects/admin.py#L10).
This uses `RelatedFieldWidgetWrapper` – which doesn’t work for radio
widgets. Demo:
[[Image(https://code.djangoproject.com/raw-attachment/ticket/34624
/related-links.gif)]]
If we look at
[https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js#L223-L230
RelatedObjectLookups.js], it seems clear this code was only written to
support `select` widgets.
Tagging this `contrib.admin` because it seems to affect all usage of
`RelatedFieldWidgetWrapper` – but as far as I can see in Django itself
only `contrib.redirects` uses radio_fields.
---
In this instance I believe a `select` widget would be a much nicer
experience anyway, so not entirely sure whether it makes sense to change
the widget to fix this, or update the code to support radio buttons, or do
both.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34624#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701887c80270c-bf16fa57-fb87-4adb-8a7b-c499afc2a3e7-000000%40eu-central-1.amazonses.com.