From 32b7d4e395cd99e1f8be835f87bd1620b7d93d54 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 5 Jan 2022 19:43:14 +0530 Subject: [PATCH] Reduce number of requests in the persons detail view + Optimize --- app/admin.py | 6 ++++++ gmba_django/settings/base.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/app/admin.py b/app/admin.py index 34589ae..05b543c 100644 --- a/app/admin.py +++ b/app/admin.py @@ -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'] diff --git a/gmba_django/settings/base.py b/gmba_django/settings/base.py index 1255a0c..1342ba3 100644 --- a/gmba_django/settings/base.py +++ b/gmba_django/settings/base.py @@ -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)