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
150
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
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
120
[PyCon Korea 2024 Session] 우리 모두는 스팸에서 자유로울 권리가 있다 - Smart Spam Filter 개발기
beomi
0
99
[2024 창구 성장 지원 세미나] LLM과 온디바이스LM으로 스팸필터 앱 서비스 만들기
beomi
0
29
[2024.08.30] Gemma-Ko, 오픈 언어모델에 한국어 입히기 @ 머신러닝부트캠프2024
beomi
0
710
[PyConKR 2019] 온라인 뉴스 댓글은 정말 사람들의 목소리일까? - PART2
beomi
3
2.9k
AWS Lambda를 통한 Tensorflow 및 Keras 기반 추론 모델 서비스하기
beomi
4
1.2k
GDG Campus SummerParty: 쓸데많은 웹 크롤러 만들기 with Python
beomi
3
1.3k
PYCON KR 2017 튜토리얼: 나만의 웹 크롤러 만들기
beomi
1
820
PYCON KR 2017: 처음부터 알아보는 웹 크롤러
beomi
3
16k
Other Decks in Technology
See All in Technology
SREの組織類型に応じた リーダシップの考察
kenta_hi
PRO
1
650
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
0
1.9k
メールサーバ管理者のみ知る話
hinono
1
110
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
390
ドメイン名の終活について - JPAAWG 7th -
mikit
32
19k
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
1
1.5k
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
2
910
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
200
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
160
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
110
Engineering at LY Corporation
lycorp_recruit_jp
0
740
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
390
Featured
See All Featured
Done Done
chrislema
181
16k
For a Future-Friendly Web
brad_frost
175
9.4k
Teambox: Starting and Learning
jrom
133
8.8k
Building Adaptive Systems
keathley
38
2.3k
Agile that works and the tools we love
rasmusluckow
327
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Designing for Performance
lara
604
68k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
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ਸ ਊ೧ ੋध