Skip to content

Commit 4204325

Browse files
committed
fix: handle empty ManyToMany relationships in UIConfigItemSerializer
- Filter out None values from Tag.loc_msg relationships to prevent LocalizedString.DoesNotExist errors - Fixes /api/2/projects/1/uiconfig/ endpoint when tags have no localized messages - Resolves issue where empty ManyToMany queries return [None] instead of [] Fixes: LocalizedString matching query does not exist error in uiconfig endpoint
1 parent 43b391a commit 4204325

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

roundware/api2/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ def to_representation(self, obj):
552552

553553
# display localized tag text in addition to tag_id
554554
tlm = Tag.objects.filter(pk=result['tag_id']).values_list('loc_msg__id', flat=True)
555+
# Filter out None values from empty ManyToMany relationships
556+
tlm = [id for id in tlm if id is not None]
555557
lm = _select_localized_string(tlm, session=session)
556558
result['tag_display_text'] = lm
557559

0 commit comments

Comments
 (0)