--
Ticket URL: <https://code.djangoproject.com/ticket/18597>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 1
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:1>
--
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:2>
* type: Cleanup/optimization => Bug
* stage: Unreviewed => Accepted
Comment:
I'm not sold on the patch -- it looks suspiciously complex -- but the
problem is real.
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:3>
* cc: hugo@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:4>
Comment (by Andreas Galazis):
This would help support prefetching configuration on parent admin's
queryset.
This is not sufficient to support prefetching since there are multiple (I
have found at least 3) instances in inline admin and inline formset where
`self.get_queryset()[i]` paradigm is used.
At least perform some code cleanup?
Even if this issue a won't fix for any reason at least abstract fetching
instance by in index in a `ge_instance_by_index` method so that we can
implement admins that do what we want of top of current base classes. If
this is done then we will be able to overwrite ge_instance_by_index to
return `list(self.get_queryset())[i]` instead of
`self.get_queryset()[i]` on inlines that support prefetching
Also I believe that the logic about preparing queryset in
BaseInlineFormSet should exist in a separate function called
`prepare_queryset`:
{{{
def prepare_queryset(queryset):
if queryset is None:
queryset = self.model._default_manager
if self.instance.pk is not None:
qs = queryset.filter(**{self.fk.name: self.instance})
else:
qs = queryset.none()
return qs
}}}
instead if throwing it `__init__`. Init could just call the above to get
the value . This way filtering wouldn't be enforced in the case of related
manager querysets since we could overwrite the method.
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:5>
* version: 1.4 => 3.2
* type: Bug => Cleanup/optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:7>
* needs_better_patch: 1 => 0
Comment:
added a PR related to the code cleanup needed to support custom inlines :
https://github.com/django/django/pull/14188
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:8>
Comment (by Andreas Galazis):
Can somebody review my PR I literally didn't change anything apart from
moving code around so that we can overwrite functionality
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:9>
Comment (by Tony Narlock):
For context, this is a blocker for a downstream plugin, see
https://github.com/theatlantic/django-nested-admin/issues/76
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:10>
* cc: Florian Demmer (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:11>
* owner: nobody => Steven Johnson
* status: new => assigned
* version: 3.2 => dev
* needs_tests: 1 => 0
Comment:
Added new pull request with docs/tests:
https://github.com/django/django/pull/17818
--
Ticket URL: <https://code.djangoproject.com/ticket/18597#comment:12>