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
Что нового в Django 1.5
Search
Moscow Python Meetup
PRO
January 24, 2013
Programming
3
1.8k
Что нового в Django 1.5
Илья Барышев (Future Colors)
Краткий обзор новых фич готовящегося релиза и советы по переходу.
Moscow Python Meetup
PRO
January 24, 2013
Tweet
Share
More Decks by Moscow Python Meetup
See All by Moscow Python Meetup
Moscow Python Meetup №103. Станислав Коленский (Самозанятый, репетитор). Как учат программированию в школьный период и на сколько можно готовить кадры с подросткового возраста
moscowdjango
PRO
0
19
Moscow Python Meetup №103. Мария Рубаненко (Fintech AI / Tech lead DS). Суперсжатие на строках
moscowdjango
PRO
0
35
Moscow Python Meetup №103. Михаил Попов (Assigna Python Backend Developer). Vibe coding. Очевидные преимущества и непоправимые угрозы
moscowdjango
PRO
0
20
Moscow Python Meetup №102 Михаил Васильев (старший специалист по машинному обучению). Поиск аномалий в данных, алгоритмы KNN и LOF
moscowdjango
PRO
0
41
Пётр Андреев (МФТИ, лектор по курсу Advanced Python). Дебри Python или как работает повседневный Python: что происходит на самом деле
moscowdjango
PRO
0
25
Moscow Python Meetup №102. Дарья Шпак (RW TECH, Руководитель группы разработчиков). Как Python каждый день выпускает кота
moscowdjango
PRO
0
36
Михаил Васильев (Cтарший специалист по машинному обучению) Поиск аномалий в данных. Алгоритмы iForest и PCA
moscowdjango
PRO
0
74
Мария Рубаненко (Fintech AI, Team lead DS) Повышаем производительность программ: мой путь к succ[ess | inct]
moscowdjango
PRO
0
110
Moscow Python Meetup №100. Зачем рекламе Python, а Python — реклама
moscowdjango
PRO
0
76
Other Decks in Programming
See All in Programming
Constant integer division faster than compiler-generated code
herumi
2
610
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
2
2.2k
Introduction to Git & GitHub
latte72
0
110
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
190
Portapad紹介プレゼンテーション
gotoumakakeru
1
130
書き捨てではなく継続開発可能なコードをAIコーディングエージェントで書くために意識していること
shuyakinjo
1
270
Android 15以上でPDFのテキスト検索を爆速開発!
tonionagauzzi
0
200
構文解析器入門
ydah
7
2.1k
Strands Agents で実現する名刺解析アーキテクチャ
omiya0555
1
120
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
580
MCPで実現できる、Webサービス利用体験について
syumai
7
2.5k
A Gopher's Guide to Vibe Coding
danicat
0
120
Featured
See All Featured
A better future with KSS
kneath
239
17k
Site-Speed That Sticks
csswizardry
10
770
Git: the NoSQL Database
bkeepers
PRO
431
65k
Code Review Best Practice
trishagee
69
19k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
A Tale of Four Properties
chriscoyier
160
23k
Why Our Code Smells
bkeepers
PRO
338
57k
How GitHub (no longer) Works
holman
314
140k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Become a Pro
speakerdeck
PRO
29
5.5k
Transcript
None
10 месяцев разработки ~1700 коммитов Переезд на гитхаб ~550 closed
PR Чуточку статистики
https://docs.djangoproject.com/en/dev/releases/1.5/ Улучшена документация • CBV • Testing Tutorial (part 5)
• Reusable apps • Writing your first patch for Django
Custom User Model
# myapp.models.py class MyUser(AbstractUser): email
= EmailField(max_length=254, ...) favorite_pony = CharField(max_length=20) ... USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['favorite_pony'] Пример custom User model
Обращаемся к модели # settings.py AUTH_USER_MODEL = 'myapp.MyUser' # Django
1.4 from django.contrib.auth.models import User # Django 1.5 from django.contrib.auth import get_user_model User = get_user_model()
AbstractUser User username first_name last_name email
is_staff is_active date_joined USERNAME_FIELD REQUIRED_FIELDS get_absolute_url() get_full_name() get_short_name()
AbstractBaseUser AbstractUser User password last_login get_username() is_anonymous() is_authenticated() set_password(...) check_password(...)
set_unusable_password() has_usable_password()
AbstractBaseUser AbstractUser User PermissionsMixin get_group_permissions(…) get_all_permissions(…) has_perm(…) has_perms(…) has_module_perms(…) is_superuser
AbstractBaseUser AbstractUser User PermissionsMixin
Составные ключи index_together = [ ["pub_date",
"deadline"], ]
product.save( update_fields=['name'] ) Частичное сохранение моделей
poll = Poll.objects.all()[0] >> 1 query choice = poll.choice_set.all()[0] >>
1 query choice.poll is poll >> 0 queries Кэширование related моделей
Streaming responses # 1.4 response = HttpResponse(content=myiterator) # 1.5 response
= StreamingHttpResponse( streaming_content=myiterator) def iterator(): for x in range(1,11): yield "%s\n" % x time.sleep(1)
{% verbatim %} {% verbatim %} {% endverbatim
%} JQuery Template {{if morning}}Drink coffee.{{/if}}
https://github.com/chrisdickinson/plate <script type="text/javascript" src="plate.js"> var template = new plate.Template(
'Hello {{ world }}'); template.render({world: 'everyone'}, function(err, data) { console.log(data) });
{{ view.template_name }} Переменная {{ view }} body.html {{ view.my_attribute
}} Hey class MyView(TemplateView): template_name = 'body.html' my_attribute = 'Hey'
# Django 1.2 {% url viewname %} # Django 1.3
{% load url from future %} {% url 'viewname' %} # Django 1.5 {% url 'viewname' %}
https://github.com/futurecolors/django-future-url django-‐make-‐future-‐url.py -‐-‐dry-‐run
QuerySet.bulk_create() работает с SQLite3 Сигнал user_login_failed Приятные мелочи Стандартные 404
и 500 {% if 'someapp.someperm' in perms %} GeoDjango PostGIS 2.0 loaddata(ignorenonexistent=True) Получение ContentType для прокси-моделей django.utils.timezone.localtime view.resolver_match django logger печататает в консоль mod_wsgi auth handler True, False, Null в шаблонах
Python 3*
Версии Python Django 1.3 Python 2.4+ Django 1.4 Python 2.5+
Django 1.5 Python 2.6+ Python 3.2+
django.utils.six в Django 1.4.2+
# python 2 for k, v in mydict.iteritems(): # python
2 & 3 import six for k,v in six.iteritems(mydict):
# python 2.6 & 3 from __future__ import print_function
print('Hello world!', end=' ') # python 2 print 'Hello world!', # python 3 print('Hello world!', end=' ')
https://github.com/mitsuhiko/python-modernize Автоматизируем six
http://python3porting.com/
None
django Pillow django-model-utils django-picklefield embedly-python pytils django-storages docutils south requests
django-discover-runner mock django-nose psycopg2 dj-database-url 3 http://moscowdjango.ru/py3/
Пробуйте Django 1.5 @ Пишите на Python 3
Спасибо
[email protected]
@coagulant http://blog.futurecolors.ru/