《Django 5 By Example》阅读笔记:p679-p765

《Django 5 By Example》学习第10天,p679-p765总结,总计87页。

一、技术总结

1.channel

书里通过聊天软件功能演示Django中channel以及异步编程的应用,本人对这块不是很熟悉,不做评价。

2.deployment(部署)

python 复制代码
services:
  db:
    image: postgres:16.2
    restart: always
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

  cache:
    image: redis:7.2.4
    restart: always
    volumes:
      - ./data/cache:/data

  web:
    build: .
    command: ["./wait-for-it.sh", "db:5432", "--",
              "uwsgi", "--ini", "/code/config/uwsgi/uwsgi.ini"]
    restart: always
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    environment:
      - DJANGO_SETTINGS_MODULE=educa.settings.prod
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    depends_on:
      - db
      - cache
  ...(其它内容省略)

看了作者的写的docker-compose.yml,这里要多说两句:

(1)在docker-compose.yml里面包含build命令,本人觉得这是一种不好的写法。因为重启服务的次数是远远多于build次数的,同时也没有必要每次都build。

(2)服务命名为db,本人觉得这是一种不好的写法。因为db的含义不明确,可以指"MySQL,Oracle,MongoDB, Redis"等,这里使用的是Postgresql数据库,那么直接用postgresql命名更好。

(3)数据库命名为postgres,本人觉得这是一种不好的写法。因为含义不明确。

二、英语总结(生词:3)

1.engage

(1)engage: en-("in") + gage("a pledge, commitment, or security,保证,承诺")。

p679, In this chapter, you will develop a chat server for students using Django Channels, enabling students to engage in real-time messaging within course chat rooms. engage的用法比较多,这里的意思是:to get involved in sth, to take part in sth.

2.emerging

p685, ASGI is the emerging Python standard for asynchronous web servers and applications.

(1)emerge: e-("out, from") + mergere("to dip ")

vi. to rise from, to rise out of.

(2) emerging

adj. starting to exist.

3.duplex

p685, WebSockets provide full-duplex communication by establishing a persistent, open, bidirectional Transmission Control Protocol (TCP) connection between servers and clients.

(1)duplex: duo-("two") + plex("to plait(把...编成辫子)")

adj. composed of two parts. n. house or other building so divided that it forms two dwelling places.

上面的full-duplex communication的意思是(全双工通信)。

三、其它

chapter 16简评:这一章涉及到前面几章的内容,如果对Django中的channel不熟,感觉不是好理解。个人觉得读下来有点混乱。

chapter 17简评:chapter 17将部署,现在流行使用Docker部署,书里使用的也是这种方式,可以说与时俱进,总体来说读下来还是比较流畅的,毕竟内容也不算发展,总之概括下来就是要多实践。唯一的缺点就是作者写的docker-compose.yml不大规范(上面已介绍,这里不再展开)。

四、参考资料

1. 编程

(1) Antonio Melé,《Django 5 By Example》:https://book.douban.com/subject/37007362/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

相关推荐
独行soc1 分钟前
2026年渗透测试面试题总结-10(题目+回答)
android·网络·python·安全·web安全·渗透测试·安全狮
aiguangyuan8 分钟前
词向量的艺术:从Word2Vec到GloVe的完整实践指南
人工智能·python·nlp
嫂子的姐夫11 分钟前
24-MD5:红人点集登录+凡客网登录
爬虫·python·逆向·小白逆向练手
不绝19115 分钟前
MonoBehavior/GameObject/Time/Transform/位移/角度旋转/缩放看向/坐标转换
开发语言·python
曲幽23 分钟前
FastAPI实战:Redis缓存与分布式锁的深度解析
redis·python·cache·fastapi·web·lock
小码过河.31 分钟前
17装饰器模式
开发语言·python·装饰器模式
gf132111139 分钟前
python_生成RPA运行数据报告
windows·python·rpa
嫂子开门我是_我哥40 分钟前
第八节:条件判断与循环:解锁Python的逻辑控制能力
开发语言·python
2301_8059629342 分钟前
树莓派的一些问题记录-1:usbboot仓库
python·gitee
深蓝电商API1 小时前
Selenium 动作链 ActionChains 高级用法
爬虫·python·selenium