《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)

相关推荐
Zhansiqi6 小时前
day42部分题目
python
小王不爱笑1327 小时前
IO 模型
开发语言·python
kishu_iOS&AI7 小时前
Conda 简要说明与常用指令
python·安全·conda
小陈工7 小时前
FastAPI性能优化实战:从每秒100请求到1000的踩坑记录
python·性能优化·django·flask·numpy·pandas·fastapi
知我Deja_Vu7 小时前
【避坑指南】ConcurrentHashMap 并发计数优化实战
java·开发语言·python
njidf7 小时前
用Python制作一个文字冒险游戏
jvm·数据库·python
呆呆小孩7 小时前
Anaconda 被误删抢救手册:从绝望到重生
python·conda
liliangcsdn7 小时前
LLM复杂数值的提取计算场景示例
人工智能·python
人工智能AI酱8 小时前
【AI深究】逻辑回归(Logistic Regression)全网最详细全流程详解与案例(附大量Python代码演示)| 数学原理、案例流程、代码演示及结果解读 | 决策边界、正则化、优缺点及工程建议
人工智能·python·算法·机器学习·ai·逻辑回归·正则化
WangLanguager8 小时前
逻辑回归(Logistic Regression)的详细介绍及Python代码示例
python·算法·逻辑回归