Opened 18 months ago

Last modified 8 weeks ago

#34624 assigned Bug

RelatedFieldWidgetWrapper links toggling isn’t working for radio widgets

Reported by: Thibaud Colas Owned by: devday
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
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 18 months ago.

Download all attachments as: .zip

Change History (13)

by Thibaud Colas, 18 months ago

Attachment: related-links.gif added

comment:1 by Thibaud Colas, 18 months ago

Description: modified (diff)

comment:2 by Thibaud Colas, 18 months ago

Description: modified (diff)

comment:3 by Natalia Bidart, 18 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, 18 months ago

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

comment:6 by Natalia Bidart, 15 months ago

Needs tests: set
Patch needs improvement: set

comment:7 by Natalia Bidart, 8 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, 8 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, 8 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, 4 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, 2 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, 8 weeks ago

Owner: set to devday
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top