images\cherry_red.png1 Python
      images\cherry_blue.png1.1 爬虫
         images\cherry_orange.png1.1.1 多线程
         images\cherry_orange.png1.1.2 B站
         images\cherry_orange.png1.1.3 zmq71多线程爬取
         images\cherry_orange.png1.1.4 jable.tv多线程爬取
            images\cherry_cyan.png1.1.4.1 jable.tv细节
         images\cherry_orange.png1.1.5 python执行js代码
         images\cherry_orange.png1.1.6 windows代理配置
      images\cherry_blue.png1.2 Linux编译升级3.9版本
      images\cherry_blue.png1.3 数据分析
         images\cherry_orange.png1.3.1 预测考研成绩
   images\cherry_red.png2 Python django
      images\cherry_blue.png2.1 目录层面说明
         images\cherry_orange.png2.1.1 urls.py
         images\cherry_orange.png2.1.2 settings.py
         images\cherry_orange.png2.1.3 M 模型数据库
         images\cherry_orange.png2.1.4 T templates/...html
         images\cherry_orange.png2.1.5 V(逻辑处理) views.py
      images\cherry_blue.png2.2 django模板
         images\cherry_orange.png2.2.1 模板标签
            images\cherry_cyan.png2.2.1.1 过滤器
            images\cherry_cyan.png2.2.1.2 标签
               images\cherry_orange_dark.png2.2.1.2.1 if/else
               images\cherry_orange_dark.png2.2.1.2.2 for
               images\cherry_orange_dark.png2.2.1.2.3 ifequal/ifnotequal
               images\cherry_orange_dark.png2.2.1.2.4 csrf_token
            images\cherry_cyan.png2.2.1.3 模板继承
         images\cherry_orange.png2.2.2 自定义标签和过滤器
      images\cherry_blue.png2.3 django模型ORM
         images\cherry_orange.png2.3.1 App应用
            images\cherry_cyan.png2.3.1.1 models.py
         images\cherry_orange.png2.3.2 SQL
            images\cherry_cyan.png2.3.2.1 新增
            images\cherry_cyan.png2.3.2.2 删除
            images\cherry_cyan.png2.3.2.3 更新
            images\cherry_cyan.png2.3.2.4 查询
         images\cherry_orange.png2.3.3 单表示例
         images\cherry_orange.png2.3.4 多表示例
         images\cherry_orange.png2.3.5 聚合查询
         images\cherry_orange.png2.3.6 分组查询
      images\cherry_blue.png2.4 django表单
         images\cherry_orange.png2.4.1 GET
         images\cherry_orange.png2.4.2 POST
         images\cherry_orange.png2.4.3 Request
      images\cherry_blue.png2.5 django视图
      images\cherry_blue.png2.6 django路由
      images\cherry_blue.png2.7 django Admin管理
      images\cherry_blue.png2.8 django组件
         images\cherry_orange.png2.8.1 Form页面组件
         images\cherry_orange.png2.8.2 Auth用户认证
         images\cherry_orange.png2.8.3 Cookie/Session
         images\cherry_orange.png2.8.4 中间件
         images\cherry_orange.png2.8.5 视图FBV/CBV
      images\cherry_blue.png2.9 django+nginx+uwsgi
      images\cherry_blue.png2.10 Python小知识
         images\cherry_orange.png2.10.1 def __int__(self):
         images\cherry_orange.png2.10.2 def __str__(self):
         images\cherry_orange.png2.10.3 @staticmethod
         images\cherry_orange.png2.10.4 @wraps
         images\cherry_orange.png2.10.5 pycharm
# -*- coding: utf-8 -*-

from django.http import HttpResponse

from TestModel.models import Test

# 数据库操作
def testdb(request):
# 初始化
response = ""
response1 = ""


# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
list = Test.objects.all()

# filter相当于SQL中的WHERE,可设置条件过滤结果
response2 = Test.objects.filter(id=1)

# 获取单个对象
response3 = Test.objects.get(id=1)

# 限制返回的数据 相当于 SQL 中的 OFFSET 0 LIMIT 2;
Test.objects.order_by('name')[0:2]

#数据排序
Test.objects.order_by("id")

# 上面的方法可以连锁使用
Test.objects.filter(name="runoob").order_by("id")

# 输出所有数据
for var in list:
response1 += var.name + " "
response = response1
return HttpResponse("<p>" + response + "</p>")