Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

10 месяцев разработки ~1700 коммитов Переезд на гитхаб ~550 closed PR Чуточку статистики

Slide 3

Slide 3 text

https://docs.djangoproject.com/en/dev/releases/1.5/ Улучшена документация • CBV • Testing Tutorial (part 5) • Reusable apps • Writing your first patch for Django

Slide 4

Slide 4 text

Custom User Model

Slide 5

Slide 5 text

#  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

Slide 6

Slide 6 text

Обращаемся к модели #  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()

Slide 7

Slide 7 text

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()

Slide 8

Slide 8 text

AbstractBaseUser AbstractUser User password last_login get_username() is_anonymous() is_authenticated() set_password(...) check_password(...) set_unusable_password() has_usable_password()

Slide 9

Slide 9 text

AbstractBaseUser AbstractUser User PermissionsMixin get_group_permissions(…) get_all_permissions(…) has_perm(…) has_perms(…) has_module_perms(…) is_superuser

Slide 10

Slide 10 text

AbstractBaseUser AbstractUser User PermissionsMixin

Slide 11

Slide 11 text

Составные ключи index_together  =  [        ["pub_date",          "deadline"], ]

Slide 12

Slide 12 text

product.save(      update_fields=['name'] ) Частичное сохранение моделей

Slide 13

Slide 13 text

poll  =  Poll.objects.all()[0] >>  1  query choice  =  poll.choice_set.all()[0] >>  1  query choice.poll  is  poll >>  0  queries Кэширование related моделей

Slide 14

Slide 14 text

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)    

Slide 15

Slide 15 text

{%  verbatim  %} {%  verbatim  %}     {%  endverbatim  %} JQuery Template {{if  morning}}Drink  coffee.{{/if}}

Slide 16

Slide 16 text

https://github.com/chrisdickinson/plate var  template  =  new  plate.Template(        'Hello  {{  world  }}'); template.render({world:  'everyone'},        function(err,  data)  {                    console.log(data)        });

Slide 17

Slide 17 text

{{  view.template_name  }} Переменная {{ view }} body.html {{  view.my_attribute  }} Hey class  MyView(TemplateView):        template_name  =  'body.html'        my_attribute  =  'Hey'

Slide 18

Slide 18 text

#  Django  1.2 {%  url  viewname  %} #  Django  1.3 {%  load  url  from  future  %} {%  url  'viewname'  %} #  Django  1.5 {%  url  'viewname'  %}

Slide 19

Slide 19 text

https://github.com/futurecolors/django-future-url django-­‐make-­‐future-­‐url.py  -­‐-­‐dry-­‐run

Slide 20

Slide 20 text

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 в шаблонах

Slide 21

Slide 21 text

Python 3*

Slide 22

Slide 22 text

Версии Python Django 1.3 Python 2.4+ Django 1.4 Python 2.5+ Django 1.5 Python 2.6+ Python 3.2+

Slide 23

Slide 23 text

django.utils.six в Django 1.4.2+

Slide 24

Slide 24 text

#  python  2 for  k,  v  in  mydict.iteritems(): #  python  2  &  3 import  six for  k,v  in  six.iteritems(mydict):

Slide 25

Slide 25 text

#  python  2.6  &  3   from  __future__  import  print_function print('Hello  world!',  end='  ') #  python  2 print  'Hello  world!', #  python  3 print('Hello  world!',  end='  ')

Slide 26

Slide 26 text

https://github.com/mitsuhiko/python-modernize Автоматизируем six

Slide 27

Slide 27 text

http://python3porting.com/

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

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/

Slide 30

Slide 30 text

Пробуйте Django 1.5 @ Пишите на Python 3

Slide 31

Slide 31 text

Спасибо [email protected] @coagulant http://blog.futurecolors.ru/