| 1 |
<style> |
| 2 |
.promo li a { |
| 3 |
float: left; |
| 4 |
width: 130px; |
| 5 |
height: 20px; |
| 6 |
text-align: center; |
| 7 |
margin: 10px 30px; |
| 8 |
padding: 150px 0 0 0; |
| 9 |
background-position: 0 50%; |
| 10 |
background-size: 130px auto; |
| 11 |
background-repeat: no-repeat; |
| 12 |
font-size: 120%; |
| 13 |
color: black; |
| 14 |
} |
| 15 |
.promo li { |
| 16 |
list-style: none; |
| 17 |
} |
| 18 |
</style> |
| 19 |
|
| 20 |
# Django REST framework 3.4 |
| 21 |
|
| 22 |
The 3.4 release is the first in a planned series that will be addressing schema |
| 23 |
generation, hypermedia support, API clients, and finally realtime support. |
| 24 |
|
| 25 |
--- |
| 26 |
|
| 27 |
## Funding |
| 28 |
|
| 29 |
The 3.4 release has been made possible a recent [Mozilla grant][moss], and by our |
| 30 |
[collaborative funding model][funding]. If you use REST framework commercially, and would |
| 31 |
like to see this work continue, we strongly encourage you to invest in its |
| 32 |
continued development by **[signing up for a paid plan][funding]**. |
| 33 |
|
| 34 |
The initial aim is to provide a single full-time position on REST framework. |
| 35 |
Right now we're over 60% of the way towards achieving that. |
| 36 |
*Every single sign-up makes a significant impact.* |
| 37 |
|
| 38 |
*Many thanks to all our [awesome sponsors][sponsors], and in particular to our premium backers, [Rover](https://www.rover.com/careers/), [Sentry](https://sentry.io/welcome/), and [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf).* |
| 39 |
|
| 40 |
--- |
| 41 |
|
| 42 |
## Schemas & client libraries |
| 43 |
|
| 44 |
REST framework 3.4 brings built-in support for generating API schemas. |
| 45 |
|
| 46 |
We provide this support by using [Core API][core-api], a Document Object Model |
| 47 |
for describing APIs. |
| 48 |
|
| 49 |
Because Core API represents the API schema in an format-independent |
| 50 |
manner, we're able to render the Core API `Document` object into many different |
| 51 |
schema formats, by allowing the renderer class to determine how the internal |
| 52 |
representation maps onto the external schema format. |
| 53 |
|
| 54 |
This approach should also open the door to a range of auto-generated API |
| 55 |
documentation options in the future, by rendering the `Document` object into |
| 56 |
HTML documentation pages. |
| 57 |
|
| 58 |
Alongside the built-in schema support, we're also now providing the following: |
| 59 |
|
| 60 |
* A [command line tool][command-line-client] for interacting with APIs. |
| 61 |
* A [Python client library][client-library] for interacting with APIs. |
| 62 |
|
| 63 |
These API clients are dynamically driven, and able to interact with any API |
| 64 |
that exposes a supported schema format. |
| 65 |
|
| 66 |
Dynamically driven clients allow you to interact with an API at an application |
| 67 |
layer interface, rather than a network layer interface, while still providing |
| 68 |
the benefits of RESTful Web API design. |
| 69 |
|
| 70 |
We're expecting to expand the range of languages that we provide client libraries |
| 71 |
for over the coming months. |
| 72 |
|
| 73 |
Further work on maturing the API schema support is also planned, including |
| 74 |
documentation on supporting file upload and download, and improved support for |
| 75 |
documentation generation and parameter annotation. |
| 76 |
|
| 77 |
--- |
| 78 |
|
| 79 |
Current support for schema formats is as follows: |
| 80 |
|
| 81 |
Name | Support | PyPI package |
| 82 |
---------------------------------|-------------------------------------|-------------------------------- |
| 83 |
[Core JSON][core-json] | Schema generation & client support. | Built-in support in `coreapi`. |
| 84 |
[Swagger / OpenAPI][swagger] | Schema generation & client support. | The `openapi-codec` package. |
| 85 |
[JSON Hyper-Schema][hyperschema] | Currently client support only. | The `hyperschema-codec` package. |
| 86 |
[API Blueprint][api-blueprint] | Not yet available. | Not yet available. |
| 87 |
|
| 88 |
--- |
| 89 |
|
| 90 |
You can read more about any of this new functionality in the following: |
| 91 |
|
| 92 |
* New tutorial section on [schemas & client libraries][tut-7]. |
| 93 |
* Documentation page on [schema generation][schema-generation]. |
| 94 |
* Topic page on [API clients][api-clients]. |
| 95 |
|
| 96 |
It is also worth noting that Marc Gibbons is currently working towards a 2.0 release of |
| 97 |
the popular Django REST Swagger package, which will tie in with our new built-in support. |
| 98 |
|
| 99 |
--- |
| 100 |
|
| 101 |
## Supported versions |
| 102 |
|
| 103 |
The 3.4.0 release adds support for Django 1.10. |
| 104 |
|
| 105 |
The following versions of Python and Django are now supported: |
| 106 |
|
| 107 |
* Django versions 1.8, 1.9, and 1.10. |
| 108 |
* Python versions 2.7, 3.2(\*), 3.3(\*), 3.4, 3.5. |
| 109 |
|
| 110 |
(\*) Note that Python 3.2 and 3.3 are not supported from Django 1.9 onwards. |
| 111 |
|
| 112 |
--- |
| 113 |
|
| 114 |
## Deprecations and changes |
| 115 |
|
| 116 |
The 3.4 release includes very limited deprecation or behavioral changes, and |
| 117 |
should present a straightforward upgrade. |
| 118 |
|
| 119 |
### Use fields or exclude on serializer classes. |
| 120 |
|
| 121 |
The following change in 3.3.0 is now escalated from "pending deprecation" to |
| 122 |
"deprecated". Its usage will continue to function but will raise warnings: |
| 123 |
|
| 124 |
`ModelSerializer` and `HyperlinkedModelSerializer` should include either a `fields` |
| 125 |
option, or an `exclude` option. The `fields = '__all__'` shortcut may be used |
| 126 |
to explicitly include all fields. |
| 127 |
|
| 128 |
### Microsecond precision when returning time or datetime. |
| 129 |
|
| 130 |
Using the default JSON renderer and directly returning a `datetime` or `time` |
| 131 |
instance will now render with microsecond precision (6 digits), rather than |
| 132 |
millisecond precision (3 digits). This makes the output format consistent with the |
| 133 |
default string output of `serializers.DateTimeField` and `serializers.TimeField`. |
| 134 |
|
| 135 |
This change *does not affect the default behavior when using serializers*, |
| 136 |
which is to serialize `datetime` and `time` instances into strings with |
| 137 |
microsecond precision. |
| 138 |
|
| 139 |
The serializer behavior can be modified if needed, using the `DATETIME_FORMAT` |
| 140 |
and `TIME_FORMAT` settings. |
| 141 |
|
| 142 |
The renderer behavior can be modified by setting a custom `encoder_class` |
| 143 |
attribute on a `JSONRenderer` subclass. |
| 144 |
|
| 145 |
### Relational choices no longer displayed in OPTIONS requests. |
| 146 |
|
| 147 |
Making an `OPTIONS` request to views that have a serializer choice field |
| 148 |
will result in a list of the available choices being returned in the response. |
| 149 |
|
| 150 |
In cases where there is a relational field, the previous behavior would be |
| 151 |
to return a list of available instances to choose from for that relational field. |
| 152 |
|
| 153 |
In order to minimize exposed information the behavior now is to *not* return |
| 154 |
choices information for relational fields. |
| 155 |
|
| 156 |
If you want to override this new behavior you'll need to [implement a custom |
| 157 |
metadata class][metadata]. |
| 158 |
|
| 159 |
See [issue #3751][gh3751] for more information on this behavioral change. |
| 160 |
|
| 161 |
--- |
| 162 |
|
| 163 |
## Other improvements |
| 164 |
|
| 165 |
This release includes further work from a huge number of [pull requests and issues][milestone]. |
| 166 |
|
| 167 |
Many thanks to all our contributors who've been involved in the release, either through raising issues, giving feedback, improving the documentation, or suggesting and implementing code changes. |
| 168 |
|
| 169 |
The full set of itemized release notes [are available here][release-notes]. |
| 170 |
|
| 171 |
[sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors |
| 172 |
[moss]: mozilla-grant.md |
| 173 |
[funding]: https://opencollective.com/django-rest-framework |
| 174 |
[core-api]: https://www.coreapi.org/ |
| 175 |
[command-line-client]: https://github.com/encode/django-rest-framework/blob/3.4.7/docs/topics/api-clients.md#command-line-client |
| 176 |
[client-library]: https://github.com/encode/django-rest-framework/blob/3.4.7/docs/topics/api-clients.md#python-client-library |
| 177 |
[core-json]: https://www.coreapi.org/specification/encoding/#core-json-encoding |
| 178 |
[swagger]: https://openapis.org/specification |
| 179 |
[hyperschema]: https://json-schema.org/latest/json-schema-hypermedia.html |
| 180 |
[api-blueprint]: https://apiblueprint.org/ |
| 181 |
[tut-7]: https://github.com/encode/django-rest-framework/blob/3.4.7/docs/tutorial/7-schemas-and-client-libraries.md |
| 182 |
[schema-generation]: ../api-guide/schemas.md |
| 183 |
[api-clients]: https://github.com/encode/django-rest-framework/blob/3.14.0/docs/topics/api-clients.md |
| 184 |
[milestone]: https://github.com/encode/django-rest-framework/milestone/35 |
| 185 |
[release-notes]: ./release-notes.md#34x-series |
| 186 |
[metadata]: ../api-guide/metadata.md#custom-metadata-classes |
| 187 |
[gh3751]: https://github.com/encode/django-rest-framework/issues/3751 |