| 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.8 |
| 21 |
|
| 22 |
The 3.8 release is a maintenance focused release resolving a large number of previously outstanding issues and laying |
| 23 |
the foundations for future changes. |
| 24 |
|
| 25 |
--- |
| 26 |
|
| 27 |
## Funding |
| 28 |
|
| 29 |
If you use REST framework commercially and would like to see this work continue, we strongly encourage you to invest in its continued development by |
| 30 |
**[signing up for a paid plan][funding]**. |
| 31 |
|
| 32 |
|
| 33 |
*We'd like to say thanks in particular our premium backers, [Rover](https://www.rover.com/careers/), [Sentry](https://sentry.io/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Machinalis](https://machinalis.com/), and [Rollbar](https://rollbar.com).* |
| 34 |
|
| 35 |
--- |
| 36 |
|
| 37 |
## Breaking Changes |
| 38 |
|
| 39 |
### Altered the behavior of `read_only` plus `default` on Field. |
| 40 |
|
| 41 |
[#5886][gh5886] `read_only` fields will now **always** be excluded from writable fields. |
| 42 |
|
| 43 |
Previously `read_only` fields when combined with a `default` value would use the `default` for create and update |
| 44 |
operations. This was counter-intuitive in some circumstances and led to difficulties supporting dotted `source` |
| 45 |
attributes on nullable relations. |
| 46 |
|
| 47 |
In order to maintain the old behavior you may need to pass the value of `read_only` fields when calling `save()` in |
| 48 |
the view: |
| 49 |
|
| 50 |
def perform_create(self, serializer): |
| 51 |
serializer.save(owner=self.request.user) |
| 52 |
|
| 53 |
Alternatively you may override `save()` or `create()` or `update()` on the serializer as appropriate. |
| 54 |
|
| 55 |
--- |
| 56 |
|
| 57 |
## Deprecations |
| 58 |
|
| 59 |
### `action` decorator replaces `list_route` and `detail_route` |
| 60 |
|
| 61 |
[#5705][gh5705] `list_route` and `detail_route` have been merge into a single `action` decorator. This improves viewset action introspection, and will allow extra actions to be displayed in the Browsable API in future versions. |
| 62 |
|
| 63 |
Both `list_route` and `detail_route` are now pending deprecation. They will be deprecated in 3.9 and removed entirely |
| 64 |
in 3.10. |
| 65 |
|
| 66 |
The new `action` decorator takes a boolean `detail` argument. |
| 67 |
|
| 68 |
* Replace `detail_route` uses with `@action(detail=True)`. |
| 69 |
* Replace `list_route` uses with `@action(detail=False)`. |
| 70 |
|
| 71 |
|
| 72 |
### `exclude_from_schema` |
| 73 |
|
| 74 |
Both `APIView.exclude_from_schema` and the `exclude_from_schema` argument to the `@api_view` decorator are now deprecated. They will be removed entirely in 3.9. |
| 75 |
|
| 76 |
For `APIView` you should instead set a `schema = None` attribute on the view class. |
| 77 |
|
| 78 |
For function based views the `@schema` decorator can be used to exclude the view from the schema, by using `@schema(None)`. |
| 79 |
|
| 80 |
--- |
| 81 |
|
| 82 |
## Minor fixes and improvements |
| 83 |
|
| 84 |
There are a large number of minor fixes and improvements in this release. See the [release notes](release-notes.md) page |
| 85 |
for a complete listing. |
| 86 |
|
| 87 |
|
| 88 |
## What's next |
| 89 |
|
| 90 |
We're currently working towards moving to using [OpenAPI][openapi] as our default schema output. We'll also be revisiting our API documentation generation and client libraries. |
| 91 |
|
| 92 |
We're doing some consolidation in order to make this happen. It's planned that 3.9 will drop the `coreapi` and `coreschema` libraries, and instead use `apistar` for the API documentation generation, schema generation, and API client libraries. |
| 93 |
|
| 94 |
[funding]: https://opencollective.com/django-rest-framework |
| 95 |
[gh5886]: https://github.com/encode/django-rest-framework/issues/5886 |
| 96 |
[gh5705]: https://github.com/encode/django-rest-framework/issues/5705 |
| 97 |
[openapi]: https://www.openapis.org/ |