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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Bruno Renié
April 03, 2012
Programming
450
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Django
Bruno Renié
April 03, 2012
More Decks by Bruno Renié
See All by Bruno Renié
Visibility for web developers
brutasse
3
480
Decentralization & real-time with PubSubHubbub
brutasse
1
190
Deployability of Python Web Applications
brutasse
17
2.4k
Stop writing settings files
brutasse
21
2.6k
Class-based Views: patterns and anti-patterns
brutasse
9
1.7k
Packager son projet Django
brutasse
4
590
Staticfiles : tout ce qu'il faut savoir, rien que ce qu'il faut savoir
brutasse
4
580
Other Decks in Programming
See All in Programming
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
140
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
A2UI という光を覗いてみる
satohjohn
1
140
Vite+ Unified Toolchain for the Web
naokihaba
0
310
Lessons from Spec-Driven Development
simas
PRO
0
200
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
6
1.2k
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
530
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
4.9k
3Dシーンの圧縮
fadis
1
770
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
680
Contextとはなにか
chiroruxx
1
330
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
400
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
200
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
240
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Rails Girls Zürich Keynote
gr2m
96
14k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
Being A Developer After 40
akosma
91
590k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Transcript
Django Webmardi - 03.04.2012 @brutasse
$ whoami
“Django is a high-level Python Web framework that encourages rapid
development and clean, pragmatic design”
None
None
Théorie
Real-world app: Cheese catalog Like / dislike cheeses Twitter authentication
$ pip install Django http://www.pip-installer.org
$ django-admin.py startproject webmardi webmardi/ ├── manage.py └── webmardi ├──
__init__.py ├── settings.py ├── urls.py └── wsgi.py
manage.py Project toolbox
$ python manage.py startpapp cheese cheese/ ├── __init__.py ├── models.py
├── tests.py └── views.py
Models ORM
from django.db import models from ..users.models import User class Cheese(models.Model):
name = models.CharField(max_length=255) image = models.ImageField(upload_to='cheese') description = models.TextField() class Taste(models.Model): cheese = models.ForeignKey(Cheese, related_name='tastes') user = models.ForeignKey(User) like = models.BooleanField(default=True) class Meta: unique_together = ('cheese', 'user')
Admin Customizable edition interface
from django.contrib import admin from .models import Cheese, Taste class
CheeseAdmin(admin.ModelAdmin): list_display = ('name', 'image') class TasteAdmin(admin.ModelAdmin): list_display = ('cheese', 'user', 'like') admin.site.register(Cheese, CheeseAdmin) admin.site.register(Taste, TasteAdmin)
Views Request handling
from django.template.response import TemplateResponse from .models import Cheese, Taste def
cheese_list(request): context = { 'cheeses': Cheese.objects.all(), } return TemplateResponse(request, 'cheese_list.html', context)
URLs HTTP routing
from django.conf.urls import patterns, url from . import views urlpatterns
= patterns('', url(r'^$', views.cheese_list, name='cheese_list'), url(r'^cheese/(?P<pk>\d+)/$', views.cheese_detail, name='cheese_detail'), url(r'^cheese/(?P<pk>\d+)/like/$', views.like_cheese, name='like_cheese'), url(r'^cheese/(?P<pk>\d+)/dislike/$', views.dislike_cheese, name='dislike_cheese'), url(r'^cheese/add/$', views.add_cheese, name='add_cheese'), )
Templates
<!-- base.html --> <html> <head> <title>{% block title %}{% endblock
%}</title> </head> <body> {% block content %}{% endblock %} </body> </html>
<!-- cheese_list.html --> {% extends "base.html" %} {% load thumbnail
markup %} {% block title %}Cheese types{% endblock %} {% block content %} {% for cheese in cheeses %} <h2>{{ cheese.name }}</h2> <img src="{% thumbnail cheese.image 300x300 crop %}"> {{ cheese.description|markdown }} {% endfor %} {% endblock %}
Tests Untested code is by definition broken
from django.core.urlresolvers import reverse from django.test import TestCase class CheeseTest(TestCase):
def test_home(self): url = reverse('cheese_list') response = self.client.get(url) self.assertContains(response, 'Cheese')
Forms Input validation / sanitization <form> rendering
from django import forms from .models import Cheese class CheeseForm(forms.ModelForm):
class Meta: model = Cheese
GIS Cryptographic signing Browser testing i18n Flash messages Atom/RSS Email
Cache Storage Logging Unicode Comments
Search Error reporting HTML5 forms Database migrations CMS REST API
Background tasks Debugging There's an app for that
Questions‽ Thanks @liip Code: https://github.com/brutasse/webmardi Slides: http://speakerdeck.com/u/brutasse