Skip to main content
100%

How to whitelist other admin lookups with Django 1.2.5

✓ Published0🌍 Public
Aandybak
Last edited Feb 10, 2011
Created on May 16, 2011

This example demonstrates how to override Django 1.2.5’s admin lookup restrictions by subclassing `ModelAdmin` and redefining the `lookup_allowed` method. It shows a whitelist approach that permits specific query parameters—such as `related__pk` and `related__custom_field`—while delegating all other checks to the parent class’s `super().lookup_allowed`. The code explicitly references Django’s `ModelAdmin` API and the `lookup_allowed` signature change in version 1.2.5, which added a `value` parameter. It relies on the built-in `super()` call to preserve default behavior for unlisted keys, illustrating a practical customization for admin list filtering.

AI-generated description

Similar vizzes