ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Django 1.5的重大改进一览

Django 1.5的重大改进一览

原创 Linux操作系统 作者:jieforest 时间:2012-12-03 20:29:58 0 删除 编辑
[i=s] 本帖最后由 jieforest 于 2012-12-3 20:29 编辑

With the announcement of Django 1.5B1 and the final release of 1.5 around the corner I thought I’d go over some of the largest new features. For those that want to see the release notes you can do so here.

Overview

The biggest new feature in Django 1.5 is the configurable User model. Before Django 1.5, applications that wanted to use Django’s auth framework (django.contrib.auth) were forced to use Django’s definition of a “user”. In Django 1.5, you can now swap out the User model for one that you write yourself. This could be a simple extension to the existing User model – for example, you could add a Twitter or Facebook ID field – or you could completely replace the User with one totally customized for your site.


Django 1.5 is also the first release with Python 3 support! We’re labeling this support “experimental” because we don’t yet consider it production-ready, but everything’s in place for you to start porting your apps to Python 3. Our next release, Django 1.6, will support Python 3 without reservations.


Other notable new features in Django 1.5 include:


1. Support for saving a subset of model’s fields - Model.save() now accepts an update_fields argument, letting you specify which fields are written back to the database when you call save(). This can help in high-concurrency operations, and can improve performance.


2. Better support for streaming responses via the new StreamingHttpResponse response class.


3. GeoDjango now supports PostGIS 2.0.


... and more; see below.


Wherever possible we try to introduce new features in a backwards-compatible manner per our API stability policy. However, as with previous releases, Django 1.5 ships with some minor backwards incompatible changes; people upgrading from previous versions of Django should read that list carefully.


One deprecated feature worth noting is the shift to “new-style” url tag. Prior to Django 1.3, syntax like {% url myview %} was interpreted incorrectly (Django considered "myview" to be a literal name of a view, not a template variable named myview). Django 1.3 and above introduced the {% load url from future %} syntax to bring in the corrected behavior. where myview was seen as a variable.


The upshot of this is that if you are not using {% load url from future %} in your templates, you’ll need to change tags like {% url myview %} to {% url "myview" %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-750471/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Redis崩溃
请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    441
  • 访问量
    602331