|
| 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 | +<ul class="premium-promo promo"> |
| 39 | + <li><a href="http://jobs.rover.com/" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/rover_130x130.png)">Rover.com</a></li> |
| 40 | + <li><a href="https://getsentry.com/welcome/" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/sentry130.png)">Sentry</a></li> |
| 41 | + <li><a href="https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/stream-130.png)">Stream</a></li> |
| 42 | +</ul> |
| 43 | +<div style="clear: both; padding-bottom: 20px;"></div> |
| 44 | + |
| 45 | +*Many thanks to all our [awesome sponsors][sponsors], and in particular to our premium backers, [Rover](http://jobs.rover.com/), [Sentry](https://getsentry.com/welcome/), and [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf).* |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Schemas & client libraries |
| 50 | + |
| 51 | +REST framework 3.4 brings built-in support for generating API schemas. |
| 52 | + |
| 53 | +We provide this support by using [Core API][core-api], a Document Object Model |
| 54 | +for describing APIs. |
| 55 | + |
| 56 | +Because Core API represents the API schema in an format-independent |
| 57 | +manner, we're able to render the Core API `Document` object into many different |
| 58 | +schema formats, by allowing the renderer class to determine how the internal |
| 59 | +representation maps onto the external schema format. |
| 60 | + |
| 61 | +This approach should also open the door to a range of auto-generated API |
| 62 | +documentation options in the future, by rendering the `Document` object into |
| 63 | +HTML documentation pages. |
| 64 | + |
| 65 | +Alongside the built-in schema support, we're also now providing the following: |
| 66 | + |
| 67 | +* A [command line tool][command-line-client] for interacting with APIs. |
| 68 | +* A [Python client library][client-library] for interacting with APIs. |
| 69 | + |
| 70 | +These API clients are dynamically driven, and able to interact with any API |
| 71 | +that exposes a supported schema format. |
| 72 | + |
| 73 | +Dynamically driven clients allow you to interact with an API at an application |
| 74 | +layer interface, rather than a network layer interface, while still providing |
| 75 | +the benefits of RESTful Web API design. |
| 76 | + |
| 77 | +We're expecting to expand the range of languages that we provide client libraries |
| 78 | +for over the coming months. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +Current support for schema formats is as follows: |
| 83 | + |
| 84 | +Name | Support | PyPI package |
| 85 | +---------------------------------|-------------------------------------|-------------------------------- |
| 86 | +[Core JSON][core-json] | Schema generation & client support. | Built-in support in `coreapi`. |
| 87 | +[Swagger / OpenAPI][swagger] | Schema generation & client support. | The `openapi-codec` package. |
| 88 | +[JSON Hyper-Schema][hyperschema] | Currrently client support only. | The `hyperschema-codec` package. |
| 89 | +[API Blueprint][api-blueprint] | Not yet available. | Not yet available. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +You can read more about any of this new functionality in the following: |
| 94 | + |
| 95 | +* New tutorial section on [schemas & client libraries][tut-7]. |
| 96 | +* Documentation page on [schema generation][schema-generation]. |
| 97 | +* Topic page on [API clients][api-clients]. |
| 98 | + |
| 99 | +It is also worth noting that Marc Gibbons is currently working towards a 2.0 release of |
| 100 | +the popular Django REST Swagger package, which will tie in with our new built-in support. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Supported versions |
| 105 | + |
| 106 | +The 3.4.0 release adds support for Django 1.10. |
| 107 | + |
| 108 | +The following versions of Python and Django are now supported: |
| 109 | + |
| 110 | +* Django versions 1.8, 1.9, and 1.10. |
| 111 | +* Python versions 2.7, 3.2(\*), 3.3(\*), 3.4, 3.5. |
| 112 | + |
| 113 | +(\*) Note that Python 3.2 and 3.3 are not supported from Django 1.9 onwards. |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## Deprecations and changes |
| 118 | + |
| 119 | +The 3.4 release includes very limited deprecation or behavioral changes, and |
| 120 | +should present a straightforward upgrade. |
| 121 | + |
| 122 | +#### Use fields or exclude on serializer classes. |
| 123 | + |
| 124 | +The following change in 3.3.0 is now escalated from "pending deprecation" to |
| 125 | +"deprecated". Its usage will continue to function but will raise warnings: |
| 126 | + |
| 127 | +`ModelSerializer` and `HyperlinkedModelSerializer` should include either a `fields` |
| 128 | +option, or an `exclude` option. The `fields = '__all__'` shortcut may be used |
| 129 | +to explicitly include all fields. |
| 130 | + |
| 131 | +#### Microsecond precision when returning time or datetime |
| 132 | + |
| 133 | +Using the default JSON renderer and directly returning a `datetime` or `time` |
| 134 | +instance will now render with microsecond precision (6 digits), rather than |
| 135 | +millisecond precision (3 digits). This makes the output format consistent with the |
| 136 | +default string output of `serializers.DateTimeField` and `serializers.TimeField`. |
| 137 | + |
| 138 | +This change *does not affect the default behavior when using serializers*, |
| 139 | +which is to serialize `datetime` and `time` instances into strings with |
| 140 | +microsecond precision. |
| 141 | + |
| 142 | +The serializer behavior can be modified if needed, using the `DATETIME_FORMAT` |
| 143 | +and `TIME_FORMAT` settings. |
| 144 | + |
| 145 | +The renderer behavior can be modified by setting a custom `encoder_class` |
| 146 | +attribute on a `JSONRenderer` subclass. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## Other improvements |
| 151 | + |
| 152 | +This release includes further work from a huge number of [pull requests and issues][milestone]. |
| 153 | + |
| 154 | +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. |
| 155 | + |
| 156 | +The full set of itemized release notes [are available here][release-notes]. |
| 157 | + |
| 158 | +[sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors |
| 159 | +[moss]: mozilla-grant.md |
| 160 | +[funding]: funding.md |
| 161 | +[core-api]: http://www.coreapi.org/ |
| 162 | +[command-line-client]: api-clients#command-line-client |
| 163 | +[client-library]: api-clients#python-client-library |
| 164 | +[core-json]: http://www.coreapi.org/specification/encoding/#core-json-encoding |
| 165 | +[swagger]: https://openapis.org/specification |
| 166 | +[hyperschema]: http://json-schema.org/latest/json-schema-hypermedia.html |
| 167 | +[api-blueprint]: https://apiblueprint.org/ |
| 168 | +[tut-7]: ../../tutorial/7-schemas-and-client-libraries/ |
| 169 | +[schema-generation]: ../../api-guide/schemas/ |
| 170 | +[api-clients]: api-clients.md |
| 171 | +[milestone]: https://github.com/tomchristie/django-rest-framework/milestone/35 |
| 172 | +[release-notes]: release-notes#34 |
0 commit comments