Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DjangoGirls Seoul | Django Study #2 Django MTV
Search
Beomi
February 12, 2017
Technology
0
140
DjangoGirls Seoul | Django Study #2 Django MTV
DjangoGirls Seoul 장고 입문 스터디 #2 Django MTV
Beomi
February 12, 2017
Tweet
Share
More Decks by Beomi
See All by Beomi
[2024 창구 성장 지원 세미나] LLM과 온디바이스LM으로 스팸필터 앱 서비스 만들기
beomi
0
13
[2024.08.30] Gemma-Ko, 오픈 언어모델에 한국어 입히기 @ 머신러닝부트캠프2024
beomi
0
370
[PyConKR 2019] 온라인 뉴스 댓글은 정말 사람들의 목소리일까? - PART2
beomi
3
2.8k
AWS Lambda를 통한 Tensorflow 및 Keras 기반 추론 모델 서비스하기
beomi
4
1.1k
GDG Campus SummerParty: 쓸데많은 웹 크롤러 만들기 with Python
beomi
3
1.3k
PYCON KR 2017 튜토리얼: 나만의 웹 크롤러 만들기
beomi
1
790
PYCON KR 2017: 처음부터 알아보는 웹 크롤러
beomi
3
16k
굥대생의 "HelloWorld!"
beomi
0
860
로지스틱 회귀 분석 | 밑바닥부터 시작하는 데이터 과학 16장
beomi
0
450
Other Decks in Technology
See All in Technology
夏休みの(最後の)宿題 for JuliaTokyo #12
antimon2
0
130
音声AIエージェントの世界とRetell AI入門 / Introduction to the World of Voice AI Agents and Retell AI
rkaga
3
490
waitany と waitall を作った話
mrkn
0
110
歴史と背景から改めて振り返るVPC
shotashiratori
2
220
Javaにおける関数型プログラミンへの取り組み
skrb
5
190
スーパーマリオRPGのリメイク版の変更点からみるUX
nishiharatsubasa
1
120
トレタO/X アーキテクチャ移行記 Next.js App Router化への道のり / TORETA TECH UPDATE 1
okunokentaro
2
570
20分で分かるIAM全機能 (拡大版) / 20240903-jawsug-yokohama-iam
opelab
3
120
Evolving DevOps Teams and Flexible Organizational Culture
kakehashi
1
140
デジタル化・DX推進あるある
y150saya
0
220
分野に潜むツールの紹介
pojiro
1
330
Namespace, Now and Then
tagomoris
0
170
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
25
1.3k
YesSQL, Process and Tooling at Scale
rocio
167
14k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Unsuck your backbone
ammeep
667
57k
How to name files
jennybc
75
97k
Practical Orchestrator
shlominoach
185
10k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
263
13k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
41
6.4k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
Designing the Hi-DPI Web
ddemaree
278
34k
Large-scale JavaScript Application Architecture
addyosmani
508
110k
Transcript
Django Girls Seoul Django Study Django Model-View-Template
MTV? MVC?
Model?
Model (ݽ؛) • Database৬ Djangoܳ োѾ • DB Column ഋधਸ
• ؘఠ ҙ҅ܳ from django.db import models class SomeInfo(models.Model): name = models.CharField(max_length=200) • nameۄח ܴ Column ࢤࢿغҊ ୭ӡо 200ਵ۽ ઁೠ Ѧܽ ٘۽ ػ.
Model Field (ݽ؛٘) • models SomeInfo ېझ => DB SomeInfo
Table • SomeInfo ېझ name => DB name Column Model Manager (ݽ؛ ݒפ) • DB Queryܳ ܻ • SomeInfo.objects.ޤޤ ࣘࢿਵ۽ ઁҕ
User Method (ࢎਊ ݫࣗ٘) • ݽ؛ ݫࣗ٘о ݽ؛ী •
SomeInfo١ ݽ؛ classউী ػ ೣࣻ
Rela%onship (ҙ҅) • ݽ؛ class݃ (DB table݃) ҙ҅ • OneToOneField(1:1)
/ ForeignKey(1:n) / ManyToManyField(n:n) class UserInfo(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL) # ਬо о ਬ ࠁח ױ ೞա! nickname = models.CharField(max_length=20) class Post(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL) # ਬо ৈ۞ѐ Ӗਸ ॶ ࣻ . title = models.CharField(max_length=200) content = models.TextField() class Tag(models.Model): post = models.ManyToManyField(Post) # ೠ Postী ৈ۞ѐ కӒо ׳ܾ ࣻ Ҋ, ೠ కӒী ৈ۞ѐ Postо .
Rela%onship (ҙ҅) • OneToOneField u = User(user=request.user) u.userinfo.nickname # user
UserInfo nickname • ForeignKey u.post_set.all() # userо ॵ ݽٚ post • ManyToManyField p = Post.objects.first() p.tag_set.all()
Template?
Template (మ݁) • Python ёܳ HTMLীࢲ ਊೡ ࣻ ب۾ •
Django Template ޙߨਸ ਊ ( Jinja2) • Viewীࢲ ֈѹח ؘఠܳ ਊ • renderೣࣻীࢲ ਊؽ • MVCݽ؛ V(࠭)ী ೧ؽ
Template (మ݁) <!-- ߸ࣻ some_var --> {{ some_var }} <!--
కӒ some_tag --> {% some_tag %} <!-- ఠ --> {{ some_var | filter }} <!-- ࢳ --> {# ࢳ #} {% comment %} {% endcomment %}
View?
View (࠭) • Djangoо URLӔী ٮۄ ߈ਸ ࠁח Ҕ •
MVCݽ؛ C(ஶ܀۞) ೡ • Func4on Based View vs Class Based View • request -> response
HTTP Request • method / / GET, POST, .. •
GET, POST -> DICT(k:v) • FILES • user • session • ...
REST? RESTful?
REST <=> CRUD
REST and CRUD • HTTP Methodח POST / GET /
PUT / DELETE • CRUDח Create / Read / Update / Delete • пп
RESTful • OpenAPI ઁҕ ए • ਗೞח ؘఠ ఋੑਵ۽
ઁҕ (JSON / XML / RSS) • StateLessࢲߡ (ਃр Contextח غ ঋ) • ۽٘ߖ۠यী ਬܻ • ࣁ࣌ ࢎਊਸ ӂೞ ঋ (п ਃী ة݀ਵ۽ ߈) • ۽Ӓੋ ١ Tokenਸ ਊ೧ ੋध