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

相关推荐
TT_441942 分钟前
python程序实现图片截图溯源功能
开发语言·python
小陈的进阶之路1 小时前
logging 日志模块笔记
python
cqbelt2 小时前
Python 并发编程实战学习笔记
笔记·python·学习
智算菩萨2 小时前
【论文复现】Applied Intelligence 2025:Auto-PU正例无标签学习的自动化实现与GPT-5.4辅助编程实战
论文阅读·python·gpt·学习·自动化·复现
小陈工3 小时前
2026年3月31日技术资讯洞察:AI智能体安全、异步编程突破与Python运行时演进
开发语言·jvm·数据库·人工智能·python·安全·oracle
老李的勺子3 小时前
Agent 记忆失效的 5 种方式:完整排查复盘
python·llm
Leo655353 小时前
动态透视报表 + 查询接口 + Excel导出
开发语言·windows·python
清水白石0083 小时前
pytest Fixture 设计实战指南:作用域、依赖链、自动清理与测试资源高效复用
python·pytest
tottoramen4 小时前
如何安装龙虾
python
QC·Rex4 小时前
AI Agent 任务规划实战:从 ReAct 到 Plan-and-Solve 的完整指南
人工智能·python·react