Skip to content

Instantly share code, notes, and snippets.

@acdha
Created December 23, 2010 20:29
Show Gist options
  • Save acdha/753504 to your computer and use it in GitHub Desktop.
Save acdha/753504 to your computer and use it in GitHub Desktop.
How to whitelist other admin lookups with Django 1.2.5
class FooAdmin(ModelAdmin):
def lookup_allowed(self, key, value):
# NOTE: Django 1.2.5 changed the call signature to add the value
# Django 1.2.4 restricted the list of allowed lookups to only those
# specified in list_filter or date_hierarchy, which doesn't help when
# we need to filter on a list with thousands of options. We'll
# override that to allow the few which we actually use:
if key in ('related__pk', 'related__custom_field'):
return True
return super(FooAdmin, self).lookup_allowed(key, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment