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
[2024.11.27] SK WaveHill Meetup - LLM Fine-tuning
beomi
0
95
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
140
[PyCon Korea 2024 Session] 우리 모두는 스팸에서 자유로울 권리가 있다 - Smart Spam Filter 개발기
beomi
0
120
[2024 창구 성장 지원 세미나] LLM과 온디바이스LM으로 스팸필터 앱 서비스 만들기
beomi
0
31
[2024.08.30] Gemma-Ko, 오픈 언어모델에 한국어 입히기 @ 머신러닝부트캠프2024
beomi
0
800
[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
830
Other Decks in Technology
See All in Technology
5分でわかるDuckDB
chanyou0311
10
3.1k
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
120
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
160
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
120
tokyo_re_Growth2024_yoshi
yoshi22
0
210
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
240
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
100
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
100
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
380
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
350
CustomCopを使ってMongoidのコーディングルールを整えてみた
jinoketani
0
140
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
230
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
A Philosophy of Restraint
colly
203
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Being A Developer After 40
akosma
87
590k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Optimising Largest Contentful Paint
csswizardry
33
3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Rails Girls Zürich Keynote
gr2m
94
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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ਸ ਊ೧ ੋध