Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.contrib import admin
4from .models import StringLookupModel
6# Exports
8__all__ = (
9 "BaseLookupAdmin",
10)
12# Models
15class BaseLookupAdmin(admin.ModelAdmin):
16 """Base class for creating Django admin models for lookups."""
18 def get_fields(self, request, obj=None):
19 return [
20 "label",
21 "value",
22 "abbr",
23 "description",
24 "is_enabled",
25 ]
27 def get_list_display(self, request):
28 return [
29 "label",
30 "abbr",
31 "value",
32 "description",
33 "is_enabled",
34 ]
36 def get_list_filter(self, request):
37 return [
38 "is_enabled",
39 ]
41 def get_prepopulated_fields(self, request, obj=None):
42 if issubclass(self.model, StringLookupModel):
43 return {'value': ["label"]}
45 return {}
47 def get_search_fields(self, request):
48 return [
49 "description",
50 "label",
51 ]