From b49486667d6aab5283bdbe04099dadf529769ceb Mon Sep 17 00:00:00 2001 From: ngfchl Date: Tue, 20 Sep 2022 16:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95U2=E7=AD=BE=E5=88=B0=EF=BC=8C?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=EF=BC=8C=E6=98=8E=E5=A4=A9=E7=BB=A7=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_test/urls.py | 1 + pt_test/views.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/pt_test/urls.py b/pt_test/urls.py index 1f0e01d..5e47c50 100644 --- a/pt_test/urls.py +++ b/pt_test/urls.py @@ -5,4 +5,5 @@ from . import views urlpatterns = [ path(r'test_import', views.test_import, name='test_import'), path(r'handle_json', views.handle_json, name='handle_json'), + path(r'test_post', views.test_post, name='test_post'), ] diff --git a/pt_test/views.py b/pt_test/views.py index 27647f2..88b1df6 100644 --- a/pt_test/views.py +++ b/pt_test/views.py @@ -51,3 +51,15 @@ def test_import(request): def handle_json(request): if request.method == 'GET': return render(request, 'pt_test/test_json.html') + + +def test_post(request): + if request.method == 'GET': + return render(request, 'pt_test/test_post.html') + else: + r = request.POST + for i, j in r.items(): + print(i, type(i)) + print(j, type(j)) + print(r) + return JsonResponse(CommonResponse.success(data=r).to_dict(), safe=False)