Skip to content

Commit de497a9

Browse files
authored
Version 3.11 (#7083)
* Version 3.11 * Added notes on OpenAPI changes for 3.11. * Minor docs tweaking * Update package version and supported versions * Use a lazy import for django.test.client.encode_mutlipart. Closes #7078
1 parent 3c1428f commit de497a9

File tree

7 files changed

+127
-8
lines changed

7 files changed

+127
-8
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ There is a live example API for testing purposes, [available here][sandbox].
5454

5555
# Requirements
5656

57-
* Python (3.5, 3.6, 3.7)
58-
* Django (1.11, 2.0, 2.1, 2.2)
57+
* Python (3.5, 3.6, 3.7, 3.8)
58+
* Django (1.11, 2.0, 2.1, 2.2, 3.0)
5959

6060
We **highly recommend** and only officially support the latest patch release of
6161
each Python and Django series.

Diff for: docs/community/3.10-announcement.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ continued development by **[signing up for a paid plan][funding]**.
144144

145145
[legacy-core-api-docs]:https://github.com/encode/django-rest-framework/blob/master/docs/coreapi/index.md
146146
[sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
147-
[funding]: community/funding.md
147+
[funding]: funding.md

Diff for: docs/community/3.11-announcement.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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.11
21+
22+
The 3.11 release adds support for Django 3.0.
23+
24+
* Our supported Python versions are now: 3.5, 3.6, 3.7, and 3.8.
25+
* Our supported Django versions are now: 1.11, 2.0, 2.1, 2.2, and 3.0.
26+
27+
This release will be the last to support Python 3.5 or Django 1.11.
28+
29+
## OpenAPI Schema Generation Improvements
30+
31+
The OpenAPI schema generation continues to mature. Some highlights in 3.11
32+
include:
33+
34+
* Automatic mapping of Django REST Framework renderers and parsers into OpenAPI
35+
request and response media-types.
36+
* Improved mapping JSON schema mapping types, for example in HStoreFields, and
37+
with large integer values.
38+
* Porting of the old CoreAPI parsing of docstrings to form OpenAPI operation
39+
descriptions.
40+
41+
In this example view operation descriptions for the `get` and `post` methods will
42+
be extracted from the class docstring:
43+
44+
```python
45+
class DocStringExampleListView(APIView):
46+
"""
47+
get: A description of my GET operation.
48+
post: A description of my POST operation.
49+
"""
50+
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
51+
52+
def get(self, request, *args, **kwargs):
53+
...
54+
55+
def post(self, request, *args, **kwargs):
56+
...
57+
```
58+
59+
## Validator / Default Context
60+
61+
In some circumstances a Validator class or a Default class may need to access the serializer field with which it is called, or the `.context` with which the serializer was instantiated. In particular:
62+
63+
* Uniqueness validators need to be able to determine the name of the field to which they are applied, in order to run an appropriate database query.
64+
* The `CurrentUserDefault` needs to be able to determine the context with which the serializer was instantiated, in order to return the current user instance.
65+
66+
Previous our approach to this was that implementations could include a `set_context` method, which would be called prior to validation. However this approach had issues with potential race conditions. We have now move this approach into a pending deprecation state. It will continue to function, but will be escalated to a deprecated state in 3.12, and removed entirely in 3.13.
67+
68+
Instead, validators or defaults which require the serializer context, should include a `requires_context = True` attribute on the class.
69+
70+
The `__call__` method should then include an additional `serializer_field` argument.
71+
72+
Validator implementations will look like this:
73+
74+
```python
75+
class CustomValidator:
76+
requires_context = True
77+
78+
def __call__(self, value, serializer_field):
79+
...
80+
```
81+
82+
Default implementations will look like this:
83+
84+
```python
85+
class CustomDefault:
86+
requires_context = True
87+
88+
def __call__(self, serializer_field):
89+
...
90+
```
91+
92+
---
93+
94+
## Funding
95+
96+
REST framework is a *collaboratively funded project*. If you use
97+
REST framework commercially we strongly encourage you to invest in its
98+
continued development by **[signing up for a paid plan][funding]**.
99+
100+
*Every single sign-up helps us make REST framework long-term financially sustainable.*
101+
102+
<ul class="premium-promo promo">
103+
<li><a href="https://getsentry.com/welcome/" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/sentry130.png)">Sentry</a></li>
104+
<li><a href="https://getstream.io/try-the-api/?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>
105+
<li><a href="https://software.esg-usa.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/esg-new-logo.png)">ESG</a></li>
106+
<li><a href="https://rollbar.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/rollbar2.png)">Rollbar</a></li>
107+
<li><a href="https://cadre.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/cadre.png)">Cadre</a></li>
108+
<li><a href="https://hubs.ly/H0f30Lf0" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/kloudless-plus-text.png)">Kloudless</a></li>
109+
<li><a href="https://lightsonsoftware.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/lightson-dark.png)">Lights On Software</a></li>
110+
<li><a href="https://retool.com/?utm_source=djangorest&utm_medium=sponsorship" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/retool-sidebar.png)">Retool</a></li>
111+
</ul>
112+
<div style="clear: both; padding-bottom: 20px;"></div>
113+
114+
*Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry](https://getsentry.com/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [ESG](https://software.esg-usa.com/), [Rollbar](https://rollbar.com/?utm_source=django&utm_medium=sponsorship&utm_campaign=freetrial), [Cadre](https://cadre.com), [Kloudless](https://hubs.ly/H0f30Lf0), [Lights On Software](https://lightsonsoftware.com), and [Retool](https://retool.com/?utm_source=djangorest&utm_medium=sponsorship).*
115+
116+
[sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
117+
[funding]: funding.md

Diff for: docs/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Some reasons you might want to use REST framework:
5252
* [Authentication policies][authentication] including packages for [OAuth1a][oauth1-section] and [OAuth2][oauth2-section].
5353
* [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources.
5454
* Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers].
55-
* [Extensive documentation][index], and [great community support][group].
55+
* Extensive documentation, and [great community support][group].
5656
* Used and trusted by internationally recognised companies including [Mozilla][mozilla], [Red Hat][redhat], [Heroku][heroku], and [Eventbrite][eventbrite].
5757

5858
---
@@ -85,8 +85,8 @@ continued development by **[signing up for a paid plan][funding]**.
8585

8686
REST framework requires the following:
8787

88-
* Python (3.5, 3.6, 3.7)
89-
* Django (1.11, 2.0, 2.1, 2.2)
88+
* Python (3.5, 3.6, 3.7, 3.8)
89+
* Django (1.11, 2.0, 2.1, 2.2, 3.0)
9090

9191
We **highly recommend** and only officially support the latest patch release of
9292
each Python and Django series.

Diff for: mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ nav:
6666
- 'Contributing to REST framework': 'community/contributing.md'
6767
- 'Project management': 'community/project-management.md'
6868
- 'Release Notes': 'community/release-notes.md'
69+
- '3.11 Announcement': 'community/3.11-announcement.md'
6970
- '3.10 Announcement': 'community/3.10-announcement.md'
7071
- '3.9 Announcement': 'community/3.9-announcement.md'
7172
- '3.8 Announcement': 'community/3.8-announcement.md'

Diff for: rest_framework/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
__title__ = 'Django REST framework'
11-
__version__ = '3.10.3'
11+
__version__ = '3.11.0'
1212
__author__ = 'Tom Christie'
1313
__license__ = 'BSD 3-Clause'
1414
__copyright__ = 'Copyright 2011-2019 Encode OSS Ltd'

Diff for: rest_framework/renderers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from django.core.paginator import Page
1717
from django.http.multipartparser import parse_header
1818
from django.template import engines, loader
19-
from django.test.client import encode_multipart
2019
from django.urls import NoReverseMatch
2120
from django.utils.html import mark_safe
2221

@@ -902,6 +901,8 @@ class MultiPartRenderer(BaseRenderer):
902901
BOUNDARY = 'BoUnDaRyStRiNg'
903902

904903
def render(self, data, accepted_media_type=None, renderer_context=None):
904+
from django.test.client import encode_multipart
905+
905906
if hasattr(data, 'items'):
906907
for key, value in data.items():
907908
assert not isinstance(value, dict), (

0 commit comments

Comments
 (0)