本文主要列举一下django orm中的常用查询的筛选方法: 大于.大于等于 小于.小于等于 in like is null / is not null 不等于/不包含于 其他模糊查询 model: 1 class User(AbstractBaseUser, PermissionsMixin): 2 uuid = ShortUUIDField(unique=True) 3 username = models.CharField(max_length=100, db_index=True, un…
ORM 查询操作 修改 views.py 文件 from django.shortcuts import render, HttpResponse from app01 import models from app01.models import Book,Author,Publisher def data_oper(req): # 获取 book 表 id 为2的价格 book = models.Book.objects.filter(id=2).values("price") pr…
单表查询: models.py: from django.db import models class Employee(models.Model): name = models.CharField(max_length=16) age = models.IntegerField() salary = models.IntegerField() province = models.CharField(max_length=32) dept = models.CharField(max_lengt…