Skip to content

Commit

Permalink
fix(relations): only serialize if there is an object
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Dec 10, 2024
1 parent 3e571bf commit b717221
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apis_core/relations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class Meta:

@extend_schema_field(SimpleObjectSerializer())
def get_subj(self, obj):
serializer = serializer_factory(type(obj.subj), SimpleObjectSerializer)
return serializer(obj.subj, context={"request": self.context["request"]}).data
if obj.subj:
serializer = serializer_factory(type(obj.subj), SimpleObjectSerializer)
return serializer(obj.subj, context={"request": self.context["request"]}).data

@extend_schema_field(SimpleObjectSerializer())
def get_obj(self, obj):
serializer = serializer_factory(type(obj.obj), SimpleObjectSerializer)
return serializer(obj.obj, context={"request": self.context["request"]}).data
if obj.obj:
serializer = serializer_factory(type(obj.obj), SimpleObjectSerializer)
return serializer(obj.obj, context={"request": self.context["request"]}).data

0 comments on commit b717221

Please sign in to comment.