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
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
160
MLOps の現場から
asei
5
610
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
140
私なりのAIのご紹介 [2024年版]
qt_luigi
1
110
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
320
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
370
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
160
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
230
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
210
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
320
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
110
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
243
12k
4 Signs Your Business is Dying
shpigford
181
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
KATA
mclloyd
29
14k
Git: the NoSQL Database
bkeepers
PRO
427
64k
A Philosophy of Restraint
colly
203
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
It's Worth the Effort
3n
183
28k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Site-Speed That Sticks
csswizardry
2
180
Making Projects Easy
brettharned
116
5.9k
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ਸ ਊ೧ ੋध