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
What's New in Django 1.3
Search
Andrew Godwin
May 25, 2011
Programming
0
93
What's New in Django 1.3
A talk I gave at DJUGL in May of 2011
Andrew Godwin
May 25, 2011
Tweet
Share
More Decks by Andrew Godwin
See All by Andrew Godwin
Reconciling Everything
andrewgodwin
1
260
Django Through The Years
andrewgodwin
0
160
Writing Maintainable Software At Scale
andrewgodwin
0
390
A Newcomer's Guide To Airflow's Architecture
andrewgodwin
0
310
Async, Python, and the Future
andrewgodwin
2
610
How To Break Django: With Async
andrewgodwin
1
660
Taking Django's ORM Async
andrewgodwin
0
670
The Long Road To Asynchrony
andrewgodwin
0
590
The Scientist & The Engineer
andrewgodwin
1
690
Other Decks in Programming
See All in Programming
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
160
From Translations to Multi Dimension Entities
alexanderschranz
2
130
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
return文におけるstd::moveについて
onihusube
1
610
Refactor your code - refactor yourself
xosofox
1
250
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
610
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Making the Leap to Tech Lead
cromwellryan
133
9k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Into the Great Unknown - MozCon
thekraken
33
1.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Bash Introduction
62gerente
608
210k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Transcript
Andrew Godwin http://www.flickr.com/photos/caroslines/1371200717/ What's new in Django 1.3?
Hi, I'm Andrew. Serial Python developer Django core committer Co-founder
of ep.io (Python hosting platform)
Django: A Very Brief History Initial release in 2005 1.0
released in 2008 1.3 released March 2011
1.3 was the "bugfix release" The plan: No major features,
quick release
1.3 was the "bugfix release" The plan: No major features,
quick release The result: 2 major features, 10 months
1.3 was the "bugfix release" The plan: No major features,
quick release The result: 2 major features, 10 months We'll get the next one out quicker...
New Features Class-based views Logging contrib.staticfiles unitttest2 on_delete TemplateResponse
Notable Changes CSRF on AJAX requests Less swearwords Translation/i18n improvements
No more mod_python No more XMLField render() shortcut
Class-Based Views Biggest change in 1.3 Not required for all
new views Designed to simplify common patterns
CBV: Before def object_detail( request, year, month, day, queryset, date_field,
month_format='%b', day_format='%d', object_id=None, slug=None, slug_field='slug', template_name=None, template_name_field=None, template_loader=loader, extra_context=None, context_processors=None, template_object_name='object', mimetype=None, allow_future=False ):
CBV: After class AccountDetail(DetailView): model = Account context_object_name = "account"
slug_field = "snail" def get_context_data(self, **kwargs): context = super(AccountDetail, self)\ .get_context_data(**kwargs) context['books'] = Book.objects.all() return context
CBV: Simple views too! class AccountDetail(TemplateView): template_name = "mytempl.html" def
get_context_data(self, **kwargs): return { "books": Book.objects.all(), "is_evil": True, }
Other uses Refactor common parts into superclasses Mixins for adding-on
functionality Mutate the input or output
Logging Now actually sensible, not just emails Uses standard Python
logging library Configured using the LOGGING setting
LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'handlers': { 'console':{
'level': 'DEBUG', 'class': 'logging.StreamHandler', }, 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', }, 'myproject.custom': { 'handlers': ['console', 'mail_admins'], 'level': 'INFO', } } }
staticfiles Lets apps ship with their static files View to
serve them in development ./manage.py collectstatic for production
unittest2 Better than unittest (obviously) Many new assertion methods Test
skipping Expected failures Much more...
unittest2 Bundled with Django Just change: import unittest from django.utils
import unittest to
on_delete Deleting rows just got better! Cascade delete (as before)
Set to NULL Raise ProtectedError Set to arbitary value
TemplateResponse A HTTPResponse class you can change Template only run
at end of middleware Change context, or even template
TemplateResponse Example from django.template.response \ import TemplateResponse def blog_index(request): return
TemplateResponse( request, 'entry_list.html', {'entries': Entry.objects.all()}, ) ... response.context_data['foo'] = 'bar'
CSRF on AJAX requests CSRF is a hard, hard problem
Flash plus 307 redirect = fail You'll have to start supplying CSRF tokens to your JavaScript
Less Swearwords Guaranteed, or your money back. Also gone: "asshat",
"asshead".
Translation / i18n Marking for ambiguous meanings Overrideable translations for
apps Deprecation of project-wide translations
No more mod_python It's dead, Jim. If you're still using
it, move to mod_wsgi or gunicorn now, please.
No more XMLField We're not really sure why it was
there in the first place.
render() shortcut Like render_to_response, but : Less characters to type
Uses RequestContext Handy for those not on CBV
How do you upgrade? Should be mostly seamless. You'll get
warnings for deprecated settings (e.g. DATABASE_NAME)
What's going to be in 1.4? We're not quite sure
yet. Possible: App refactor HTML5 doctype ORM changes
Future features GSOC should give us: Template engine refactor New
form rendering Schema alteration low-level API Composite fields
Thank you. Andrew Godwin @andrewgodwin
[email protected]