Просмотр исходного кода

Fixes #15608: Avoid caching values of null fields in search index

Jeremy Stretch 1 год назад
Родитель
Сommit
282dc7a705
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      netbox/netbox/search/__init__.py

+ 3 - 2
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):