From d1f111c509cc596bcdca458b865c5372dcf92f4a Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Thu, 4 Apr 2024 18:32:59 +0400 Subject: [PATCH] Remove provision for missing fields on `Hit` (#4027) --- api/api/serializers/base.py | 3 --- api/api/serializers/media_serializers.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/api/api/serializers/base.py b/api/api/serializers/base.py index 185a3507463..2230045a3ab 100644 --- a/api/api/serializers/base.py +++ b/api/api/serializers/base.py @@ -16,9 +16,6 @@ def build_property_field(self, field_name, model_class): """ klass, kwargs = super().build_property_field(field_name, model_class) - kwargs |= { - "allow_null": True, # model computed properties are not present in ``Hit`` - } if doc := getattr(model_class, field_name).__doc__: kwargs.setdefault("help_text", doc) return klass, kwargs diff --git a/api/api/serializers/media_serializers.py b/api/api/serializers/media_serializers.py index c47219b693b..baa91e9bf90 100644 --- a/api/api/serializers/media_serializers.py +++ b/api/api/serializers/media_serializers.py @@ -728,7 +728,7 @@ def to_representation(self, *args, **kwargs): # Ensure license is lowercase output["license"] = output["license"].lower() - if output["license_url"] is None: + if output.get("license_url") is None: output["license_url"] = get_license_url( output["license"], output["license_version"] )