#12203: ManyToManyField with through model can't be used in admin
-------------------------------------+-------------------------------------
Reporter: David Gouldin | Owner: Rosana
| Rufer
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: M2M, admin, | Triage Stage: Accepted
through, through_fields |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Collin Anderson):
Similar to #9475, I think this "through" restriction is pretty artificial
at this point (since #6707 and #9475) and the restriction can probably be
removed.
Example PR here: https://github.com/django/django/pull/18594 (I don't
plan on pushing this through myself but feel free to take it over.)
Everything should just work. Though, yes, if you filter the admin queryset
and save, it's going to delete all of the existing rows that don't match
your queryset. That's the behavior I would expect, though maybe I could
see that being confusing if Inlines/FormSets don't delete instances that
don't match your queryset? Is that the issue?
M2M docs say "For example, if an owner can own multiple cars and cars can
belong to multiple owners – a many to many relationship – you could filter
the Car foreign key field to only display the cars owned by the User"
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany
Inline docs refer to just `ModelAdmin.get_queryset()`
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-
options
`ModelAdmin.get_queryset` says: " One use case for overriding this method
is to show objects owned by the logged-in user"
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_queryset
--
Ticket URL: <https://code.djangoproject.com/ticket/12203#comment:25>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070192018d6471-12cee24e-8482-40f6-8731-774c93c8bd4a-000000%40eu-central-1.amazonses.com.