Opened 11 months ago

Last modified 5 weeks ago

#34624 new Bug

RelatedFieldWidgetWrapper links toggling isn’t working for radio widgets

Reported by: Thibaud Colas Owned by:
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 11 months ago.

Download all attachments as: .zip

Change History (10)

by Thibaud Colas, 11 months ago

Attachment: related-links.gif added

comment:1 by Thibaud Colas, 11 months ago

Description: modified (diff)

comment:2 by Thibaud Colas, 11 months ago

Description: modified (diff)

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

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

comment:5 by Coen van der Kamp, 9 months ago

Has patch: set

comment:6 by Natalia Bidart, 9 months ago

Needs tests: set
Patch needs improvement: set

comment:7 by Natalia Bidart, 6 weeks 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, 5 weeks 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, 5 weeks 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!

Note: See TracTickets for help on using tickets.
Back to Top