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

相关推荐
databook5 小时前
Manim实现闪光轨迹特效
后端·python·动效
Juchecar6 小时前
解惑:NumPy 中 ndarray.ndim 到底是什么?
python
用户8356290780516 小时前
Python 删除 Excel 工作表中的空白行列
后端·python
Json_6 小时前
使用python-fastApi框架开发一个学校宿舍管理系统-前后端分离项目
后端·python·fastapi
数据智能老司机13 小时前
精通 Python 设计模式——分布式系统模式
python·设计模式·架构
数据智能老司机14 小时前
精通 Python 设计模式——并发与异步模式
python·设计模式·编程语言
数据智能老司机14 小时前
精通 Python 设计模式——测试模式
python·设计模式·架构
数据智能老司机14 小时前
精通 Python 设计模式——性能模式
python·设计模式·架构
c8i14 小时前
drf初步梳理
python·django
每日AI新事件14 小时前
python的异步函数
python