随笔 - 3  文章 - 27  评论 - 0  阅读 - 10374 

先看图

准备工作

一、前端:参数准备vehicle_number / phone

复制代码
search(){
   uni.request({
       url: 'http://192.168.1.78:8000/api_v1/customer/get_customer_info/',
       method: 'GET',
       header:{
          Authorization: 'Bearer '+'jJlYzU0ZTRhYjNiMzYyZjE3MGFjMWU1ZDhkIiwidXNlcl9pcWlau4ptC2k'
       },
       data: {
         vehicle_number:this.vehicle_number,
         phone: this.phone
       },
       success: res => {
           console.log(res);
                    },
       });
 },
复制代码

二 、后台:获取参数

复制代码
from django.db.models import Q
class CustomerViewSet(ModelViewSet):
    queryset = Customer.objects.all()
    serializer_class = CustomerSerializer

    def get_queryset(self):
        vehicle_number = self.request.query_params.get('vehicle_number')
        phone = self.request.query_params.get('phone')
  
return Customer.objects.filter(Q(vehicle__vehicle_number=vehicle_number) | Q(phone=phone))
复制代码

三、前台:展示数据

success: res => {
   console.log(res);
  this.customer = res.data },

ulist=>展示她

posted on 2023-01-04 14:06  koolman  阅读(39)  评论(0)    收藏  举报
编辑推荐:
· C#.Net筑基-泛型T & 协变逆变
· dotnet 代码调试方法
· DbContext是如何识别出实体集合的
· 一次 .NET 性能优化之旅:将 GC 压力降低 99%
· MySQL索引完全指南:让你的查询速度飞起来
阅读排行:
· .NET中全新的MongoDb ORM框架 - SqlSugar
· 我救了一个网站,性能提升了1500 多倍!
· dotnet 代码调试方法
· .NET程序员的多语言笔记本:Polyglot Notebook
· 别再被 Spring Security 和 Shiro 劝退了!这款国产 Java 权限框架真香!
点击右上角即可分享
微信分享提示