Source code for superdjango.db.lookups.admin

# Imports

from django.contrib import admin
from .models import StringLookupModel

# Exports

__all__ = (
    "BaseLookupAdmin",
)

# Models


[docs]class BaseLookupAdmin(admin.ModelAdmin): """Base class for creating Django admin models for lookups."""
[docs] def get_fields(self, request, obj=None): return [ "label", "value", "abbr", "description", "is_enabled", ]
[docs] def get_list_display(self, request): return [ "label", "abbr", "value", "description", "is_enabled", ]
[docs] def get_list_filter(self, request): return [ "is_enabled", ]
[docs] def get_prepopulated_fields(self, request, obj=None): if issubclass(self.model, StringLookupModel): return {'value': ["label"]} return {}
[docs] def get_search_fields(self, request): return [ "description", "label", ]