From 74c692ba213279300db42797b2aeced5626b3071 Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Fri, 30 Oct 2020 21:09:32 +0200 Subject: [PATCH] Fix ModelAdmin documentation example The `get_extra_class_names_for_field_col` seems to have an `if` missing and uses an undefined `balance`. --- CONTRIBUTORS.rst | 1 + docs/reference/contrib/modeladmin/indexview.rst | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 1bfe1e40eb..1da5406f41 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -483,6 +483,7 @@ Contributors * Cole Maclean * Noah H * David Bramwell +* Naglis Jonaitis Translators =========== diff --git a/docs/reference/contrib/modeladmin/indexview.rst b/docs/reference/contrib/modeladmin/indexview.rst index 9cba1c598a..63f31020ba 100644 --- a/docs/reference/contrib/modeladmin/indexview.rst +++ b/docs/reference/contrib/modeladmin/indexview.rst @@ -554,12 +554,12 @@ depending on the row's value, you could do something like: list_display = ('name', 'account_number', 'balance') def get_extra_class_names_for_field_col(self, obj, field_name): - field_name == 'balance': - if balance <= Decimal('-100.00'): + if field_name == 'balance': + if obj.balance <= Decimal('-100.00'): return ['brand-danger'] - if balance <= Decimal('-0.00'): + elif obj.balance <= Decimal('-0.00'): return ['brand-warning'] - if balance <= Decimal('-50.00'): + elif obj.balance <= Decimal('50.00'): return ['brand-info'] else: return ['brand-success']