《Django 5 By Example》學習第3天,p54-p75總結,總計22頁。
一、技術總結
1.分頁
(1)分頁:Paginator
(2)頁數不存在處理: EmptyPage, PageNotAnInteger
2.class-based views(類檢視)
(1)為什麼使用類檢視?
1)Organize code related to HTTP methods, such as GET, POST, or PUT, in separate methods, instead of using conditional branching(使用類檢視可以根據http請求方法來組織檢視,而不是條件判斷)。
2)Use multiple inheritance to create reusable view classes (also known as mixins)(使用多繼承來實現檢視複用)。
3.forms(表單)
主要是兩類:Form, ModelForm。不過表單在實際的開發中用得較少。
二、英語總結(生詞:2)
1.canonical
p55, Using canonical URLs for models.
(1)canon
c. a rule, principle or law.
(2)canonical
adj. according to a rule.
2.facilitate
(1)facilitate: facili("easy to do"),
vt. to make sth easier(促進). p76, To facilitate the separation of configuration from code, we are going to use python-decouple.
三、其它
今天沒有什麼想說的。
四、參考資料
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)