Opened 4 months ago

Last modified 4 months ago

#36365 closed Bug

Admin filter_horziontal with formfield_for_manytomany hides existing records — at Version 2

Reported by: Ramon Owned by:
Component: contrib.admin Version: 4.2
Severity: Normal Keywords: admin, filter_horizontal
Cc: Ramon Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramon)

Django admin filter_horizontal for manytomany field should show all existing relations in the right-side pane, even when formfield_for_manytomany updates the queryset to not show that relation in the left-side pane. It is misleading to the user to not show the existing relation.

Working example attached (example.zip).
Database: club, member, team.
member and team belong to one club
team consists of members
member can transfer to another club, causing the issue.

admin.py contains two versions of the team admin model (1 and 2)
Screenshots for each admin model usage are attached.
In screenshot 2 the record Member (5) is not shown in the right-side pane, while it is present in the database.

Change History (5)

by Ramon, 4 months ago

Attachment: example.zip added

by Ramon, 4 months ago

Attachment: screenshot_admin_1.png added

by Ramon, 4 months ago

Attachment: screenshot_admin_2.png added

comment:1 by Ramon, 4 months ago

Description: modified (diff)

comment:2 by Ramon, 4 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top