《Django 5 By Example》閱讀筆記:p645-p650

codists發表於2024-11-18

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

相關文章