Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Django
Search
Mahdi Yusuf
May 21, 2015
Programming
540
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Django
Small talk I did for our local Python Group!
Mahdi Yusuf
May 21, 2015
More Decks by Mahdi Yusuf
See All by Mahdi Yusuf
Eight Fallacies of Distributed Systems
myusuf3
0
89
Better Health Insights by Unlocking Data
myusuf3
0
150
Optimizing Your Life
myusuf3
1
170
How To Make Friends and Influence Developers
myusuf3
3
1.2k
Twisted History of Python Packaging
myusuf3
11
15k
Other Decks in Programming
See All in Programming
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
1
280
続・コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions-again
handlename
0
150
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
170
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
150
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
140
JIS keyboard support in Omarchy
lef237
0
170
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
350
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.9k
AI-Powered Domain-Driven Design
ziobrando
0
360
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
140
ChromeでローカルLLM
ryu1013
0
180
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
170
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
230
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
410
Become a Pro
speakerdeck
PRO
31
6.3k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
590
WENDY [Excerpt]
tessaabrams
14
40k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Why Our Code Smells
bkeepers
PRO
340
58k
Mind Mapping
helmedeiros
1
420
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
Introduction to Django @myusuf3 because who reads documentation
What is Django? The D is silent.
BlogIt The future of online writing, maybe.
$ django-admin startproject blogit blogit ├── blogit │ ├── __init__.py
│ ├── settings.py │ ├── urls.py │ └── wsgi.py └── manage.py
$ django-admin startapp blog * be sure to add new
app in settings file
from django.db import models class Author(models.Model): name = models.CharField(max_length=50) class
Blog(models.Model): title = models.CharField(max_length=200) text = models.TextField() pub_date = models.DateTimeField('date published', auto_now_add=True,) author = models.ForeignKey(Author)
$ python manage.py makemigrations blog
Migrations for 'blog': 0001_initial.py: - Create model Author - Create
model Blog
$ python manage.py migrate
Operations to perform: Synchronize unmigrated apps: staticfiles, messages Apply all
migrations: admin, blog, contenttypes, auth, sessions Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying blog.0001_initial... OK
View from Top The steward of control
def post(request, post_id): post = get_object_or_404(Blog, pk=post_id) return render(request, 'post.html',
{'post': post})
Templates and Rendering Making things look beautiful
<h1>{{ post.title }}</h1> <h4> Posted: {{ post.pub_date }}</h4> <h4>Author: {{post.author.name}}</h4>
<p> {{post.text}} </p>
Feature Request! CEO has epiphany!!
def latest(request): posts = Blog.objects.all() return render(request, 'posts.html', {'posts': posts})
{% for post in posts %} <h1>{{ post.title }}</h1> <h4>
Posted: {{ post.pub_date }}</h4> <h4>Author: {{post.author.name}}</h4> <p> {{post.text}} </p> {% endfor %}
Requirements Got a list checking it twice!
dj-database-url==0.3.0 dj-static==0.0.6 Django==1.8 gevent==1.0.1 greenlet==0.4.5 gunicorn==19.3.0 honcho==0.6.6 psycopg2==2.6 static3==0.5.1 static==1.1.1
What is Deploying? The D isn’t silent, just like in
the word difficult.
Inquiries? @myusuf3 Do something magical now!