1 | 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.
|
---|
2 |
|
---|
3 | This method receives value 'employee__person_ptr__exact' in paramter 'lookup'.
|
---|
4 |
|
---|
5 | The 'lookup' is splitted by the lookup_seperator ('--'). Code snippet:
|
---|
6 |
|
---|
7 | 209 parts = lookup.split(LOOKUP_SEP)
|
---|
8 |
|
---|
9 | So, 'parts' will now contain: ['employee', 'person_ptr', 'exact']
|
---|
10 |
|
---|
11 |
|
---|
12 | The last term is ignored since it is a query term. Code snippet:
|
---|
13 |
|
---|
14 | 211 # Last term in lookup is a query term (__exact, __startswith etc)
|
---|
15 | 212 # This term can be ignored.
|
---|
16 | 213 if len(parts) > 1 and parts[-1] in QUERY_TERMS:
|
---|
17 | 214 parts.pop()
|
---|
18 |
|
---|
19 | Now 'parts' contains: ['employee', 'person_ptr']
|
---|
20 |
|
---|
21 | 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:
|
---|
22 |
|
---|
23 | 235 try:
|
---|
24 | 236 self.model._meta.get_field_by_name(parts[0])
|
---|
25 | 237 except FieldDoesNotExist:
|
---|
26 | 238 # Lookups on non-existants fields are ok, since they're ignored
|
---|
27 | 239 # later.
|
---|
28 | 240 return True
|
---|
29 | 241 else:
|
---|
30 | 242 if len(parts) == 1:
|
---|
31 | 243 return True
|
---|
32 | 244 clean_lookup = LOOKUP_SEP.join(parts)
|
---|
33 | 245 return clean_lookup in self.list_filter or clean_lookup == self.date_hierarchy
|
---|
34 |
|
---|