From 67967bbff924938a77aa6e517d05bc7db45d4f6d Mon Sep 17 00:00:00 2001 From: cococo <17401091+kingmo888@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:32:20 +0800 Subject: [PATCH] Update views_front.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决前台偶发500问题 --- api/views_front.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/views_front.py b/api/views_front.py index 8b40d14..9eb2367 100644 --- a/api/views_front.py +++ b/api/views_front.py @@ -186,8 +186,9 @@ def get_all_info(): for peer in peers: user = UserProfile.objects.filter(Q(id=peer.uid)).first() - devices[peer.rid]['rust_user'] = user.username - + device = devices.get(peer.rid, None) + if device: + devices['rust_user'] = user.username return [v for k,v in devices.items()] @@ -203,4 +204,4 @@ def work(request): all_info = get_all_info() print(all_info) - return render(request, 'show_work.html', {'single_info':single_info, 'all_info':all_info, 'u':u}) \ No newline at end of file + return render(request, 'show_work.html', {'single_info':single_info, 'all_info':all_info, 'u':u})