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

相关推荐
曲幽1 小时前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
荣码1 小时前
用Streamlit给AI应用套个界面,10行代码出Web页面
java·python
兵慌码乱11 小时前
基于Python+PyQt5+SQLite的药房管理系统实现:事务一致性与界面解耦全流程解析
python·sqlite·信号与槽·pyqt5·数据库设计·桌面应用开发·事务处理
金銀銅鐵12 小时前
[Python] 体验用欧几里得算法计算最大公约数的过程
python·数学
FreakStudio16 小时前
W55MH32L-EVB 上手测评:硬件 TCP/IP 加持的以太网单片机,MicroPython 零门槛开发
python·单片机·嵌入式·大学生·面向对象·并行计算·电子diy·电子计算机
用户03321266636717 小时前
使用 Python 从零创建 Word 文档
python
Csvn1 天前
Python 两大经典坑点 —— 可变默认参数 & 闭包延迟绑定
后端·python
曲幽1 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
用户556918817531 天前
#从脚本到独立程序:Python + Playwright 批量抓取的完整踩坑记录
python·自动化运维
兵慌码乱2 天前
基于 MediaPipe 与 PySide2 的手势交互音乐控制系统实现:轻量化视觉交互全流程解析
python·opencv·计算机视觉·人机交互·手势识别·mediapipe·pyside2