From 70a40841a1360c72892d1d9b230ba7e7e0b2a654 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Tue, 30 Aug 2022 13:48:25 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=A7=84=E5=88=99=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=84=E5=88=99=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 8 ++++++-- templates/auto_pt/restart.html | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/auto_pt/views.py b/auto_pt/views.py index a1ea30e..c5011c9 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -210,8 +210,12 @@ def do_update(request): print(data[2]) print(data[0].get('url')) for site in data: - del site['pk'] - Site.objects.update_or_create(defaults=site, url=site.get('url')) + print(site) + if site.get('pk'): + del site['pk'] + print(site) + site_obj = Site.objects.update_or_create(defaults=site, url=site.get('url')) + print(site_obj) return JsonResponse(data=CommonResponse.success( msg='更新成功!!', data=result diff --git a/templates/auto_pt/restart.html b/templates/auto_pt/restart.html index c8c3d7b..7cbfb14 100644 --- a/templates/auto_pt/restart.html +++ b/templates/auto_pt/restart.html @@ -22,6 +22,7 @@ {# 刷新页面#} + 更新 更新 重启