From 6326972b8fdc02e1278ecbdf1986ff7fa4e44397 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 18 Feb 2022 15:33:03 -0500 Subject: [PATCH] [rentals] Make LockerInfo blind code and bitting code editable in changelist --- rentals/admin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rentals/admin.py b/rentals/admin.py index 640ad72..17d7c5b 100644 --- a/rentals/admin.py +++ b/rentals/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django import forms from .models import LockerBank, LockerInfo, LockerUnit @@ -30,6 +31,14 @@ class LockerInfoAdmin(admin.ModelAdmin): list_filter = ["locker_unit__bank", "locker_unit", "renter"] list_display = ["locker_unit", "address", "blind_code", "bitting_code", "renter"] list_display_links = ["locker_unit", "address"] + list_editable = ["blind_code", "bitting_code"] def get_queryset(self, request): return LockerInfo.objects.select_related("locker_unit", "locker_unit__bank") + + def get_changelist_formset(self, request, **kwargs): + kwargs["widgets"] = { + "blind_code": forms.TextInput(attrs={"size": 6}), + "bitting_code": forms.TextInput(attrs={"size": 6}), + } + return super().get_changelist_formset(request, **kwargs)