Changes between Version 4 and Version 5 of Ticket #32587


Ignore:
Timestamp:
Mar 24, 2021, 7:27:29 AM (4 years ago)
Author:
Andreas Galazis
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32587 – Description

    v4 v5  
    55
    66Even 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
     7
     8Also I believe that the logic about preparing queryset in BaseInlineFormSet should exist in a separate function called `prepare_queryset`:
     9
     10
     11{{{
     12def prepare_queryset(queryset):
     13        if queryset is None:
     14            queryset = self.model._default_manager
     15        if self.instance.pk is not None:
     16            qs = queryset.filter(**{self.fk.name: self.instance})
     17        else:
     18            qs = queryset.none()
     19        return qs
     20}}}
     21instead if throwing it `__init__` Intit 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.
Back to Top