django-rest-framework/docs/topics/3.1-announcement.md

96 lines
4.8 KiB
Markdown
Raw Normal View History

2015-01-30 19:27:49 +03:00
# Django REST framework 3.1
2015-02-03 12:15:42 +03:00
The 3.1 release is an intermediate step in the Kickstarter project releases, and includes a range of new functionality.
2015-01-30 19:27:49 +03:00
## Pagination
2015-02-03 12:15:42 +03:00
The pagination API has been improved, making it both easier to use, and more powerful.
#### New pagination schemes.
Until now, there has only been a single built-in pagination style in REST framework. We now have page, limit/offset and cursor based schemes included by default.
The cursor based pagination scheme is particularly smart, and is a better approach for clients iterating through large or frequently changing result sets. The scheme supports paging against non-unique indexes, by using both cursor and limit/offset information. Credit to David Cramer for [this blog post](http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api/) on the subject.
2015-01-30 19:27:49 +03:00
#### Pagination controls in the browsable API.
2015-02-03 12:15:42 +03:00
Paginated results now include controls that render directly in the browsable API. If you're using the page or limit/offset style, then you'll see a page based control displayed in the browsable API.
**IMAGE**
The cursor based pagination renders a more simple 'Previous'/'Next' control.
**IMAGE**
2015-01-30 19:27:49 +03:00
#### Support for header-based pagination.
2015-02-03 12:15:42 +03:00
The pagination API was previously only able to alter the pagination style in the body of the response. The API now supports being able to write pagination information in response headers, making it possible to use pagination schemes that use the `Link` or `Content-Range` headers.
**TODO**: Link to docs.
2015-01-30 19:27:49 +03:00
## Versioning
2015-02-03 12:15:42 +03:00
We've made it easier to build versioned APIs. Built-in schemes for versioning include both URL based and Accept header based variations.
When using a URL based scheme, hyperlinked serializers will resolve relationships to the same API version as used on the incoming request.
**TODO**: Example.
2015-01-30 19:27:49 +03:00
## Internationalization
2015-02-03 12:15:42 +03:00
REST framework now includes a built-in set of translations, and supports internationalized error responses. This allows you to either change the default language, or to allow clients to specify the language via the `Accept-Language` header.
**TODO**: Example.
**TODO**: Credit.
## New field types
Django 1.8's new `ArrayField`, `HStoreField` and `UUIDField` are now all fully supported.
This work also means that we now have both `serializers.DictField()`, and `serializers.ListField()` types, allowing you to express and validate a wider set of representations.
2015-01-31 11:53:40 +03:00
2015-01-30 19:27:49 +03:00
## ModelSerializer API
2015-02-03 12:15:42 +03:00
The serializer redesign in 3.0 did not include any public API for modifying how ModelSerializer classes automatically generate a set of fields from a given mode class. We've now re-introduced an API for this, allowing you to create new ModelSerializer base classes that behave differently, such as using a different default style for relationships.
**TODO**: Link to docs.
## Moving packages out of core
We've now moved a number of packages out of the core of REST framework, and into separately installable packages. If you're currently using these you don't need to worry, you simply need to `pip install` the new packages, and change any import paths.
2015-02-05 02:32:25 +03:00
We're making this change in order to help distribute the maintainance workload, and keep better focus of the core essentials of the framework.
2015-02-03 12:15:42 +03:00
2015-02-05 02:32:25 +03:00
The change also means we can be more flexible with which external packages we recommend. For example, the excellently maintained [Django OAuth toolkit](https://github.com/evonove/django-oauth-toolkit) has now been promoted as our recommended option for integrating OAuth support.
2015-02-03 12:15:42 +03:00
2015-02-05 02:32:25 +03:00
The following packages are now moved out of core and should be separately installed:
2015-02-03 12:15:42 +03:00
2015-02-05 02:32:25 +03:00
* OAuth - [djangorestframework-oauth](http://jpadilla.github.io/django-rest-framework-oauth/)
* XML - [djangorestframework-xml](http://jpadilla.github.io/django-rest-framework-xml)
* YAML - [djangorestframework-yaml](http://jpadilla.github.io/django-rest-framework-yaml)
* JSONP - [djangorestframework-jsonp](http://jpadilla.github.io/django-rest-framework-jsonp)
It's worth reiterating that this change in policy shouldn't mean any work in your codebase other than adding a new requirement and modifying some import paths. For example to install XML rendering, you would now do:
pip install djangorestframework-xml
And modify your settings, like so:
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
'rest_framework_xml.renderers.XMLRenderer'
]
}
2015-02-03 12:15:42 +03:00
# What's next?
The next focus will be on HTML renderings of API output and will include:
* HTML form rendering of serializers.
* Filtering controls built-in to the browsable API.
* An alternative admin-style interface.
This will either be made as a single 3.2 release, or split across two separate releases, with the HTML forms and filter controls coming in 3.2, and the admin-style interface coming in a 3.3 release.