Opened 2 years ago
Last modified 6 weeks ago
#34402 new Bug
Admin searchfields for inherited model — at Initial Version
Description ¶
Hello everyone!
Let's have model Payer
and we will create ExtendedPayer
from it
class ExtendedPayer(Payer): ...
We create admin for ExtendedPayer
and define search fields. We want to be able to filter by pk
of Payer
. So I would expect these to work the same:
class ExtendedPayerAdmin(ModelAdmin): ... search_fields = ( "pk__iexact", ... ) ...
class ExtendedPayerAdmin(ModelAdmin): ... search_fields = ( "id__iexact", ... ) ...
Guess what? The "id" variant works ok and the "pk" fails with
Why? Because in construct_search
(See Git) it's transformed to pk__iexact__icontains
as it found out that the pk
is payer_ptr
which is FK.
If we want to be correct, it should be "payer_ptr__pk__iexact"
.
Please let me know if this behaviour is a bug or if is there any reason behind it.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.