Admin filter_horziontal with formfield_for_manytomany hides existing records
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
(6)
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Resolution: |
→ invalid
|
Status: |
new → closed
|
Hello Ramon, thank you for taking the time to create this ticket. I have reviewed the attached sample project (thanks for including that) and also the screenshots. Below a few notes:
main
).formfield_for_manytomany
is explicitely leavingMember object (5)
(nameMember 21
) outside the queryset. Why would this member, that belongs to another club (Club 2
), be listed in this page where your custom model admin is explicitly excluding those entries?Because of the above, this report seems better suited to be a support request. The best place to get answers to your issue is using any of the user support channels from this link.
Since the goal of this issue tracker is to track issues about Django itself, and your issue seems, at first, to be located in your custom code, I'll be closing this ticket as
invalid
following the ticket triaging process. If, after debugging, you find out that this is indeed a bug in Django, please re-open with the specific details.Thank you!