From 9fad59154579f45ba1ee28a1e14dd4ae6452a8ab Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Tue, 22 Oct 2024 16:32:06 +0800 Subject: [PATCH] fix: Historical sessions download failed --- apps/terminal/serializers/session.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/terminal/serializers/session.py b/apps/terminal/serializers/session.py index 91928431d..99c4e9511 100644 --- a/apps/terminal/serializers/session.py +++ b/apps/terminal/serializers/session.py @@ -64,8 +64,9 @@ class SessionSerializer(BulkOrgResourceModelSerializer): return fields def pop_fields_if_need(self, fields): - if self.context['request'].method != "GET": - fields.pop("command_amount") + request = self.context.get('request') + if request and request.method != 'GET': + fields.pop("command_amount", None) def validate_asset(self, value): max_length = self.Meta.model.asset.field.max_length