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
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
レトロゲームから学ぶ通信技術の歴史
kimkim0106
0
110
効率的な開発手段として VRTを活用する
ishkawa
0
160
テスターからテストエンジニアへ ~新米テストエンジニアが歩んだ9ヶ月振り返り~
non0113
2
220
階層化自動テストで開発に機動力を
ickx
0
150
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
1.1k
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
250
DMMを支える決済基盤の技術的負債にどう立ち向かうか / Addressing Technical Debt in Payment Infrastructure
yoshiyoshifujii
4
420
PHPカンファレンス関西2025 基調講演
sugimotokei
3
200
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
880
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
620
MCPを使ってイベントソーシングのAIコーディングを効率化する / Streamlining Event Sourcing AI Coding with MCP
tomohisa
0
170
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
It's Worth the Effort
3n
185
28k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Side Projects
sachag
455
42k
Done Done
chrislema
184
16k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
108
19k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Speed Design
sergeychernyshev
32
1k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
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!