django.core.exceptions.ImproperlyConfigured: 'django.db.backends.data' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-
in backends, use 'django.db.backends.XXX', where XXX is one of:
'oracle', 'postgresql', 'sqlite3'
在django执行迁移时发现设置里面没有链接到mysql模块,只发现了 'oracle', 'postgresql', 'sqlite3'这三个模块,
怎样才能将mysql模块设置到到python目录下的django里面?
没有那就没有,django更换下版本
【相关推荐】
templates 目录下创建 user.html
内容如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>用户</title>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<p>
用户列表
<button id="getlist">点击刷新</button>
</p>
<ul id="list">
<li>空</li>
</ul>
<div>
<h2>注册</h2>
<p>用户名:<input type="text" id="username"></p>
<p>密码:<input type="text" id="pw"></p>
<p>
<button id="register">注册</button>
</p>
<p id="msg"></p>
</div>
<script>
let csrf_token = '{{ csrf_token }}'
$(function () {
$("#getlist").click(function () {
$.ajax({
url: '/user/getusers',
type: 'get',
headers: {
// 要加 csrf 的请求头,如下
"X-CSRFToken": csrf_token
},
// 告诉服务器返回信息要以json格式返回
dataType: "json",
}).done(function (result) {
// 打印返回结果
console.log(result)
// 将返回信息插入到页面中
let text = result.data.map(user => {
return `<li>用户id:${user.id},用户名:${user.username}</li>`
}).join('')
if (text.length === 0) {
text = '<li>没有加载到数据</li>'
}
$("#list").html(text)
})
})
$("#register").click(function () {
$.ajax({
url: '/user/register',
type: 'post',
headers: {
// 要加 csrf 的请求头,如下
"X-CSRFToken": csrf_token,
// 要改请求头,以 json 格式发送信息
'Content-Type': 'application/json',
},
// 发送的数据要先转为 json 格式
data: JSON.stringify({
username: $("#username").val(),
pw: $("#pw").val()
}),
// 告诉服务器返回信息要以json格式返回
dataType: "json",
}).done(function (result) {
// 打印返回结果
console.log(result)
// 将返回信息插入到页面中
$("#msg").html(result.msg)
})
})
})
</script>
</body>
</html>
两个功能: