Ticket #15044: overrule_lookup_method.txt

File overrule_lookup_method.txt, 633 bytes (added by rene, 14 years ago)

Overrule lookup method in your 'ModelAdmin' object

Line 
1def lookup_allowed(self, lookup):
2 allowed = super(admin.ModelAdmin, self).lookup_allowed(lookup)
3 if not allowed:
4 from django.db.models.sql.constants import LOOKUP_SEP, QUERY_TERMS
5
6 parts = lookup.split(LOOKUP_SEP)
7
8 # Last term in lookup is a query term (__exact, __startswith etc)
9 # This term can be ignored.
10 if len(parts) > 1 and parts[-1] in QUERY_TERMS:
11 parts.pop()
12 clean_lookup = LOOKUP_SEP.join(parts)
13 if clean_lookup == "medewerker__user_ptr":
14 allowed = True
15
16 return allowed
Back to Top