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
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
250
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
170
Terraform Stacks入門 #HashiTalks
msato
0
330
OCI Security サービス 概要
oracle4engineer
PRO
0
6.4k
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
490
[OCI Technical Deep Dive] Oracle Cloud VMware Solution が開くVMware仮想環境モダナイゼーションへの道(2024年10月29日開催)
oracle4engineer
PRO
0
110
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
1
1.5k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
0
740
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
110
Windows Autopilot Deployment by OSD Guy
tamaiyutaro
0
410
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.7k
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
2k
Why Our Code Smells
bkeepers
PRO
334
57k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
A Philosophy of Restraint
colly
203
16k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Cult of Friendly URLs
andyhume
78
6k
Unsuck your backbone
ammeep
668
57k
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ਸ ਊ೧ ੋध