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
Introduction to Django
Search
Mahdi Yusuf
May 21, 2015
Programming
1
520
Introduction to Django
Small talk I did for our local Python Group!
Mahdi Yusuf
May 21, 2015
Tweet
Share
More Decks by Mahdi Yusuf
See All by Mahdi Yusuf
Eight Fallacies of Distributed Systems
myusuf3
0
51
Better Health Insights by Unlocking Data
myusuf3
0
110
Optimizing Your Life
myusuf3
1
150
How To Make Friends and Influence Developers
myusuf3
3
1.1k
Twisted History of Python Packaging
myusuf3
11
14k
Other Decks in Programming
See All in Programming
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
400
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
190
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
700
GPUを計算資源として使おう!
primenumber
1
170
AI時代の『改訂新版 良いコード/悪いコードで学ぶ設計入門』 / ai-good-code-bad-code
minodriven
20
8.1k
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
790
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
190
NPOでのDevinの活用
codeforeveryone
0
860
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
140
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
740
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
840
Featured
See All Featured
Become a Pro
speakerdeck
PRO
29
5.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
We Have a Design System, Now What?
morganepeng
53
7.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
BBQ
matthewcrist
89
9.7k
Code Review Best Practice
trishagee
69
19k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
Optimizing for Happiness
mojombo
379
70k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
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!