python - django中的并发请求
问题描述
从 vue 对 Django API 的并发请求会返回对两者的最后一个请求的响应。
这是我的 vue 组件片段
methods:{
users(){
axios.get('users').then((response) => {
this.sers = response.data;
}).catch((error) => {
console.log(error);
});
},
new_users(){
axios.get('users', {
params: {type:'new'},
}).then((response) => {
this.new_users = response.data;
}).catch((error) => {
console.log(error);
});
}
},
mounted(){
this.users();
this.new_users();
}
和我的 Django 视图中的 python 片段
def list_objects(request):
if 'type' in request.GET and request.GET['type'] =='new' :
#return new users
else:
#return users
问题是 new_users() 和 users() 方法响应新用户数据(最后调用的那个,如果我们最后调用 users() 方法,这两个方法都获取用户数据)
解决方案
问题出在 Django 开发服务器上。当我切换到gunicorn时,所有问题都消失了,现在按预期工作。
推荐阅读
- postgresql - 有没有办法在 pgadmin 中插入驼峰表名?
- java - 如何在没有 xml 的情况下配置 Ehcache 3 + spring boot + java config?
- javascript - 检查自上次点击后的时间是否大于 2 秒
- c# - 标签中的文本被截断
- python - numpy linalg中的特征值排序
- database - 将备用时间戳格式插入 Hive
- javascript - 如何将两个 JavaScript 合并为一个
- php - 从 php 检索数据到 jquery 并将其插入 DataTable
- ruby - 我的 ruby 脚本的守护进程日志在哪里
- typescript - 在编译时强制指定两个道具之一?