The exception is raised because in file django/contrib/admin/options.py the method lookup_allowed in class BaseModelAdmin will return 'False' for this filter query.

This method receives value 'employee__person_ptr__exact' in paramter 'lookup'.

The 'lookup' is splitted by the lookup_seperator ('--'). Code snippet:

209	        parts = lookup.split(LOOKUP_SEP)

So, 'parts' will now contain: ['employee', 'person_ptr', 'exact']


The last term is ignored since it is a query term. Code snippet:

211	        # Last term in lookup is a query term (__exact, __startswith etc)
212	        # This term can be ignored.
213	        if len(parts) > 1 and parts[-1] in QUERY_TERMS:
214	            parts.pop()

Now 'parts' contains: ['employee', 'person_ptr']

The first element from 'parts' is tried to be a 'field' of the class. 'employee' indeed is, so the 'else' part of the exception handler is executed. A variable 'clean_lookup' is made which concats the two values of 'parts' together. 'clean_lookup' has the value 'employee__person_ptr'. This string is not included in 'list_filter' and not included in 'date_hierarchy'. So 'False' is returned. Lookup is not allowed. Code snippet:

235		try:
236	            self.model._meta.get_field_by_name(parts[0])
237	        except FieldDoesNotExist:
238	            # Lookups on non-existants fields are ok, since they're ignored
239	            # later.
240	            return True
241	        else:
242	            if len(parts) == 1:
243	                return True
244	            clean_lookup = LOOKUP_SEP.join(parts)
245	            return clean_lookup in self.list_filter or clean_lookup == self.date_hierarchy

