《Django 5 By Example》学习第8天,p645-p650总结,总计6页。
一、技术总结
1.django-rest-framework
(1)serializer
p648, Serializer: Provides serialization for normal Python class instances。Serializer又细分为Serializer, ModelSerializer, HyperlinkedModelSerializer.
2.目录结构
.courses├── __init__.py├── admin.py├── api│ ├── __init__.py│ ├── serializer.py│ └── views.py├── apps.py├── fields.py├── fixtures│ └── subjects.json├── forms.py├── migrations│ ├── 0001_initial.py│ ├── 0002_video_text_image_file_content.py│ ├── 0003_alter_content_options_alter_module_options_and_more.py│ ├── 0004_course_students.py│ └── __init__.py├── models.py├── output.txt├── static│ └── css├── templates│ ├── base.html│ ├── courses│ └── registration├── templatetags│ ├── __init__.py│ └── course.py├── tests.py├── urls.py└── views.py
引入django-rest-framework后,API相关的代码放到api目录,如上所示。
二、英语总结(生词:2)
1.bookmark vs bookmarklet
(1)bookmark
c. a piece of thick paper, leather or plastic that you put betweent the pages of a book so that you can find a page again quickly(书签).
(2)bookmarklet
A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser(书签工具).
2.negotiation
p650, The framework determines which renderer to use through content negotiation by inspecting the request’s Accept header to determine the expected content type for the response.
(1)negotiate
neg-("not") + otium("ease, leisure"). 字面意思是"lack of leisure(空闲)",后来演变为"have formal discussions with someone in order to reach an agreement with them(协商)"之意。
三、其它
书上的项目太多了,我自己则是比较关心django-rest-framework的使用,因为这是实际工作中用得最多的。鉴于此,作者在第15章引入django-rest-framework,所以直接跳到第15张开始学习。
四、参考资料
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)