《Django 5 By Example》阅读笔记:p543-p550

《Django 5 By Example》学习第 19 天,p543-p550 总结,总计 8 页。

一、技术总结

1.fixtures

(1)定义

A fixture is a collection of files that contain the serialized contents of the database.

(2)作用

1)数据导入

一般来说,我们是通过数据库工具(如:Navicat,DBeaver)进行数据导入和导出。在 Django中,也可以通过 fixtures 结合 duamdata 、loaddata 命令进行数据导入导出。

单纯从数据导入导出这点来说,我更倾向于使用数据库工具进行操作,因为这更通用。

(3)示例

注:educa是 project, courses 是 application。

python 复制代码
educa# mkdir courses/fixture

educa# python manage.py dumpdata courses --indent=2 --output=courses/fixtures/subjects.json

educa# python manage.py loaddata subjects.json

2.model inheritance

Django中有三种类型 model inheritance:

(1)abstract model

(2)multi-table model inheritance

(3)proxy model

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

1.polymorphism

(1)polymorph

poly-("many") + morph("form, shape")

(2)polymorphism: polymorph + -ism

u. the fact the sth can exist in different forms(多态性)。

(3)polymorphous vs polymorphic

adj. having many different forms(多态的)。polymorphous 和 polymorphic的意思是一样的,他们之间的区别是:

1)polymorphous

Commonly used as a descriptive term in general contexts, including art, literature, and natural sciences.

示例:Water is a polymorphous substance, taking the form of ice, liquid, or vapor.

2)polymorphic

Often used in technical or scientific contexts, such as programming, biology, or chemistry.

示例:The class exhibits polymorphic behavior by overriding methods in different subclasses.

2.provision

(1)provision: pro-("before, forward") + vision(from videre, "to see")

字面意思是"to see beforehand(预先看看)", "to prepare in advance(提前准备)",后面演变为:c/u. the act of providing sth。

(2)provide: provision 是 provide 的名词形式。

p546, Polymorphism is the provision of a single interface to entities of different types(多态是为不同类型的实体提供单一接口).

三、其它

今天没有什么想说的。

四、参考资料

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)

相关推荐
用户0190275816114 小时前
新浪财经 / 东方财富股票接口不稳、被限?稳定替代方案
python
七夜zippoe14 小时前
Nexent 知识库:调优靠 Chunk 与重排
开发语言·python·ai智能体·nexent·知识库与rag
承渊政道17 小时前
【Python编程—从入门到实践】(用户账户:给Django网站装上登录系统,让每个人拥有自己的学习笔记)
python·学习·pycharm·django
承渊政道18 小时前
【Python编程—从入门到实践】(设置样式并部署:给Django网站换新装,把学习笔记发布到互联网)
python·学习·pycharm·django
用户2986985301418 小时前
使用 Python 将 JSON 转换为 Word 文档的实践指南
python·json·api
卷无止境19 小时前
AI 加速开发之后,如何应对尚未发现的代码安全威胁
后端·python
cpolar技术支持19 小时前
容器数是 6 个、6 个、还是 6 个,可服务早被换掉了:用一个 5.5MB 的 Go 单文件把机器每周的变化记下来,再给它套一层别人看不懂的入口
python·docker·ai·cpolar
ONEYAC唯样19 小时前
YXC扬兴科技小型化有源晶振OT4JI-111-24M,提升红外热成像稳定性
人工智能·python·pygame
威哥爱编程20 小时前
模拟面试智能体开发实战 09:把面试官装进手机,鸿蒙端聊天界面用 SSE 流式输出让回复逐字滚出来
python·agent·harmonyos
威哥爱编程20 小时前
模拟面试智能体开发实战 10:配置写死在代码里还怎么换服务端,把设置和简历做成界面可配、可存
python·agent·harmonyos