Opened 19 months ago

Last modified 2 weeks ago

#34624 assigned Bug

RelatedFieldWidgetWrapper links toggling isn’t working for radio widgets

Reported by: Thibaud Colas Owned by: JaeHyuckSa
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: yes

Description (last modified by Thibaud Colas)

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:

https://code.djangoproject.com/raw-attachment/ticket/34624/related-links.gif

If we look at 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.

Attachments (1)

related-links.gif (31.4 KB ) - added by Thibaud Colas 19 months ago.

Download all attachments as: .zip

Change History (17)

by Thibaud Colas, 19 months ago

Attachment: related-links.gif added

comment:1 by Thibaud Colas, 19 months ago

Description: modified (diff)

comment:2 by Thibaud Colas, 19 months ago

Description: modified (diff)

comment:3 by Natalia Bidart, 19 months ago

Triage Stage: UnreviewedAccepted

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.

comment:4 by Coen van der Kamp, 19 months ago

I'll will first attempt 2.a: "Actually fix the admin's RelatedFieldWidgetWrapper to work with radioselect".

comment:6 by Natalia Bidart, 17 months ago

Needs tests: set
Patch needs improvement: set

comment:7 by Natalia Bidart, 9 months ago

Has patch: unset
Needs tests: unset
Owner: Coen van der Kamp removed
Patch needs improvement: unset
Status: assignednew
Version: 4.2dev

comment:8 by Anirudh Prabhakaran, 9 months ago

Hello! What is the status of this ticket?

I am planning to apply for GSoC, and so I think that trying to solve a ticket would give me a chance to get my hands dirty with the codebase. If this is not assigned to anyone, can I take a look?

in reply to:  8 comment:9 by Natalia Bidart, 9 months ago

Replying to Anirudh Prabhakaran:

Hello! What is the status of this ticket?

I am planning to apply for GSoC, and so I think that trying to solve a ticket would give me a chance to get my hands dirty with the codebase. If this is not assigned to anyone, can I take a look?

Hello Anirudh, this ticket is free to be worked on. You can use the existing PR as a starting point. Thanks for wanting to contribute to Django!

comment:10 by Sasa Cocic-Banjanac, 5 months ago

This ticket looks unassigned and it seems no one is currently working on it. I'd like to try to tackle it and put up a PR if there are no objections.

in reply to:  10 comment:11 by bartalor, 3 months ago

Replying to Sasa Cocic-Banjanac:

This ticket looks unassigned and it seems no one is currently working on it. I'd like to try to tackle it and put up a PR if there are no objections.

Are you still working on the issue ?
if not, I'd like to try have a go on it :)

comment:12 by devday, 3 months ago

Owner: set to devday
Status: newassigned

comment:13 by JaeHyuckSa, 2 weeks ago

Owner: changed from devday to JaeHyuckSa

comment:14 by JaeHyuckSa, 2 weeks ago

I will submit a PR by the end of today.

comment:15 by JaeHyuckSa, 2 weeks ago

Has patch: set

comment:16 by Sarah Boyce, 2 weeks ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top