forked from Mirrors/Dispatcharr
Merge pull request #659 from FiveBoroughs/fix/channel-stream-order-serialization
Fix: Preserve stream order in ChannelSerializer PATCH/PUT responses
This commit is contained in:
commit
204a5a0c76
1 changed files with 11 additions and 2 deletions
|
|
@ -294,8 +294,17 @@ class ChannelSerializer(serializers.ModelSerializer):
|
|||
|
||||
if include_streams:
|
||||
self.fields["streams"] = serializers.SerializerMethodField()
|
||||
|
||||
return super().to_representation(instance)
|
||||
return super().to_representation(instance)
|
||||
else:
|
||||
# Fix: For PATCH/PUT responses, ensure streams are ordered
|
||||
representation = super().to_representation(instance)
|
||||
if "streams" in representation:
|
||||
representation["streams"] = list(
|
||||
instance.streams.all()
|
||||
.order_by("channelstream__order")
|
||||
.values_list("id", flat=True)
|
||||
)
|
||||
return representation
|
||||
|
||||
def get_logo(self, obj):
|
||||
return LogoSerializer(obj.logo).data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue