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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "related-links.gif" added.
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.
>
> 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:
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:1>
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>
* stage: Unreviewed => Accepted
Comment:
Accepting since I could easily reproduce the issue. In my opinion, we
could perhaps do two things:
1- Separately consider whether the `redirects` app should be changed to
use a select instead of a radioselect (think of a project with lots of
Django Sites, the radio buttons would consume a lot of screen) This would
be a separated ticket for the `redirects` site.
2- Actually fix the admin's RelatedFieldWidgetWrapper to work with
radioselect or clealry document that only selects are supported.
--
Ticket URL: <https://code.djangoproject.com/ticket/34624#comment:3>
Comment (by Coen van der Kamp):
I'll will first attempt 2.a: "Actually fix the admin's
RelatedFieldWidgetWrapper to work with radioselect".
--
Ticket URL: <https://code.djangoproject.com/ticket/34624#comment:4>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/17158
--
Ticket URL: <https://code.djangoproject.com/ticket/34624#comment:5>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34624#comment:6>