as shown in the figure, a simple add and query operation takes up to 1 second [environment: windows + python3 + django2]. (the amount of data in PS: is not much, and todo_list has only 2 rows of data, which is still so slow.)
def get(request):
-sharp /todo/list
todo_list = list( Todo.objects.all().values("name") )
return JsonResponse({
"code": 0,
"data": todo_list
})
@post_method
def add(request):
-sharp /todo/add
item = Todo.objects.create(name=request.POST["name"])
return JsonResponse({
"code": 0,
"msg": "add successfully."
})
the mysql, used in the database will not be so slow if the default sqlite3 is used.
-sharp settings.py
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "ops_chart",
"USER": "root",
"PASSWORD": "xxxxxx",
"HOST": "localhost",
"PORT": "3306",
"OPTIONS": {
"sql_mode": "STRICT_TRANS_TABLES"
}
}
}