#33375: Admin changelist_formset does not use the Admin queryset
----------------------------------+--------------------------------------
Reporter: François Freitag | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by François Freitag):
* status: closed => new
* resolution: needsinfo =>
Comment:
Hi Carlton,
Thanks for looking into it! The `ManagementForm` was indeed missing from
my patch. It was also missing `_save=on`.
With these changes, the issue triggers in the correct code path. I’ll
update the attached patch immediately.
`modified_objects` is indeed the views queryset, including soft-deleted
objects. However, the formset `id` field used the default queryset. Here’s
the behavior I’m seeing while step-debugging the code:
{{{
>
/home/freitafr/dev/django/django/contrib/admin/options.py(1765)changelist_view()
-> if formset.is_valid():
(Pdb) l
1760 raise PermissionDenied
1761 FormSet = self.get_changelist_formset(request)
1762 breakpoint()
1763 modified_objects =
self._get_list_editable_queryset(request, FormSet.get_default_prefix())
1764 formset = cl.formset = FormSet(request.POST,
request.FILES, queryset=modified_objects)
1765 -> if formset.is_valid():
1766 changecount = 0
1767 for form in formset.forms:
1768 if form.has_changed():
1769 obj = self.save_form(request, form,
change=True)
1770 self.save_model(request, obj, form,
change=True)
(Pdb) n
>
/home/freitafr/dev/django/django/contrib/admin/options.py(1795)changelist_view()
-> if formset:
(Pdb) p formset.is_valid()
False
(Pdb) p formset.errors
[{'id': ['Select a valid choice. That choice is not one of the available
choices.']}, {}]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33375#comment:3>
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/073.ab03dde2b93ba6a7c3d808b37d70464c%40djangoproject.com.