Reduce number of requests in the persons detail view + Optimize

This commit is contained in:
PCoder 2022-01-05 19:43:14 +05:30
parent f8b0dbcf4a
commit 32b7d4e395
2 changed files with 8 additions and 0 deletions

View file

@ -2,14 +2,19 @@ from django.contrib import admin
from django.utils.html import format_html
from .models import *
from django.forms import TextInput
from django.conf import settings
class PeopleResourceInline(admin.TabularInline):
autocomplete_fields = ['resource']
model = PeopleResource
extra = 0
class PeopleRangeInline(admin.TabularInline):
autocomplete_fields = ['range']
model = PeopleRange
extra = 0
class PersonAdmin(admin.ModelAdmin):
@ -60,6 +65,7 @@ class PersonAdmin(admin.ModelAdmin):
)
list_display = ['id', 'full_name', 'organization']
autocomplete_fields = ['organization']
list_per_page = settings.ADMIN_LIST_PER_PAGE
# list_display_links = ['id']

View file

@ -118,3 +118,5 @@ STATIC_URL = '/static/'
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
ADMIN_LIST_PER_PAGE = os.getenv('ADMIN_LIST_PER_PAGE', 20)