From 282dc7a705240b29838731869a8ed2acef53b2b6 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 3 Apr 2024 16:18:34 -0400 Subject: [PATCH] Fixes #15608: Avoid caching values of null fields in search index --- netbox/netbox/search/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netbox/netbox/search/__init__.py b/netbox/netbox/search/__init__.py index 590188f21..7537c0419 100644 --- a/netbox/netbox/search/__init__.py +++ b/netbox/netbox/search/__init__.py @@ -59,9 +59,10 @@ class SearchIndex: @staticmethod def get_field_value(instance, field_name): """ - Return the value of the specified model field as a string. + Return the value of the specified model field as a string (or None). """ - return str(getattr(instance, field_name)) + if value := getattr(instance, field_name): + return str(value) @classmethod def get_category(cls):