﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36126	DisallowedModelAdminLookup on simple filters of FK fields with inheritance child model as target	Omar BENHAMID		"To reproduce :

1. Have an FK to a model which inherits another in models.py :

{{{
class Parent(Model):
     #...
     pass


class Child(Parent):
     #...
     pass

class FooBar(Model):
      child = ForeignKey(Child, on_delete=models.CASCADE)
}}}

2. Have a simple list filter on that fk admin.py:
{{{
class FooBarModelAdmin(ModelAdmin):
    model = FooBar
    list_filter = (""child"",)
}}}

3. Go to the admin of FooBar and try to filter by ""child"" you get :
{{{
django.contrib.admin.exceptions.DisallowedModelAdminLookup: Filtering by child__parent_ptr__exact not allowed
}}}

**Workaround:** override  {{{lookup_allowed(...)}}} in the FooBarModelAdmin to allow lookup on {{{child__parent_ptr__exact}}}.

I think that the better fix would be to filter by child_exact rather than {{{child__parent_ptr__exact}}}to avoid exposing some ""unnecessary"" technical detail, but maybe it has side effects, so the default {{{lookup_allowed(...)}}} should at least allow it.

"	Bug	closed	contrib.admin	5.1	Normal	worksforme		Omar BENHAMID	Unreviewed	0	0	0	0	0	0
