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 11, 2024
1 parent 7cd93e7 commit 163f3f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apis_core/relations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ 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 163f3f8

Please sign in to comment.