Flask==1.1.1 pymongo==3.10.1 flask-restplus==0.13.0我正在嘗試將JSON放到URL并使用,但我遇到了一個(gè)問題。在 routes.py 我有一個(gè)簡(jiǎn)單的API設(shè)置...update()@api.route('/api/content/<idx>')class UpdateContent(Resource): def put(self,idx): data = api.payload Content.objects(content_id=idx).update(**data) return jsonify(Content.objects(content_id=idx))使用Postman I are PUTting to /api/content/2 { "content_id": 2, "title": "Test 2", "description": "Test 2" }我收到這個(gè)...Traceback (most recent call last): File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask_restplus/api.py", line 584, in error_router return original_handler(e) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise raise value.with_traceback(tb) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jyoseph/Sites/testsite/venv/lib/python3.8/site-packages/flask_restplus/api.py", line 584, in error_router return original_handler(e)
Flask/Pymongo/Restplus - 使用 update(**data)
阿波羅的戰(zhàn)車
2022-08-16 19:01:18