Skip to content

Commit 84e9013

Browse files
committed
Merge pull request #3531 from tomchristie/version-3.3
Version 3.3
2 parents 9a78db2 + b2fb0de commit 84e9013

File tree

9 files changed

+96
-103
lines changed

9 files changed

+96
-103
lines changed

docs/api-guide/filtering.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ We can override `.get_queryset()` to deal with URLs such as `http://example.com/
8383

8484
As well as being able to override the default queryset, REST framework also includes support for generic filtering backends that allow you to easily construct complex searches and filters.
8585

86+
Generic filters can also present themselves as HTML controls in the browsable API and admin API.
87+
88+
![Filter Example](../img/filter-controls.png)
89+
8690
## Setting filter backends
8791

8892
The default filter backends may be set globally, using the `DEFAULT_FILTER_BACKENDS` setting. For example.

docs/img/filter-controls.png

46.8 KB
Loading

docs/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
---
1414

15-
**Note**: This is the documentation for the **version 3.2** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
16-
17-
For more details see the 3.2 [announcement][3.2-announcement] and [release notes][release-notes].
15+
**Note**: This is the documentation for the **version 3** of REST framework. Documentation for [version 2](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
1816

1917
---
2018

@@ -31,7 +29,7 @@ For more details see the 3.2 [announcement][3.2-announcement] and [release notes
3129
<img alt="Django REST Framework" title="Logo by Jake 'Sid' Smith" src="img/logo.png" width="600px" style="display: block; margin: 0 auto 0 auto">
3230
</p>
3331

34-
Django REST framework is a powerful and flexible toolkit that makes it easy to build Web APIs.
32+
Django REST framework is a powerful and flexible toolkit for building Web APIs.
3533

3634
Some reasons you might want to use REST framework:
3735

@@ -52,13 +50,14 @@ Some reasons you might want to use REST framework:
5250

5351
REST framework requires the following:
5452

55-
* Python (2.6.5+, 2.7, 3.2, 3.3, 3.4, 3.5)
53+
* Python (2.7, 3.2, 3.3, 3.4, 3.5)
5654
* Django (1.7+, 1.8, 1.9)
5755

5856
The following packages are optional:
5957

6058
* [Markdown][markdown] (2.1.0+) - Markdown support for the browsable API.
6159
* [django-filter][django-filter] (0.9.2+) - Filtering support.
60+
* [django-crispy-forms][django-crispy-forms] - Improved HTML display for filtering.
6261
* [django-guardian][django-guardian] (1.1.1+) - Object level permissions support.
6362

6463
## Installation
@@ -203,6 +202,7 @@ General guides to using REST framework.
203202
* [3.0 Announcement][3.0-announcement]
204203
* [3.1 Announcement][3.1-announcement]
205204
* [3.2 Announcement][3.2-announcement]
205+
* [3.3 Announcement][3.3-announcement]
206206
* [Kickstarter Announcement][kickstarter-announcement]
207207
* [Release Notes][release-notes]
208208

@@ -317,6 +317,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
317317
[3.0-announcement]: topics/3.0-announcement.md
318318
[3.1-announcement]: topics/3.1-announcement.md
319319
[3.2-announcement]: topics/3.2-announcement.md
320+
[3.3-announcement]: topics/3.3-announcement.md
320321
[kickstarter-announcement]: topics/kickstarter-announcement.md
321322
[release-notes]: topics/release-notes.md
322323

docs/topics/3.3-announcement.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Django REST framework 3.3
2+
3+
The 3.3 release marks the final work in the Kickstarter funded series. We'd like to offer a final resounding **thank you** to all our wonderful sponsors and supporters.
4+
5+
The amount of work that has been achieved as a direct result of the funding is immense. We've added a huge amounts of new functionality, resolved nearly 2,000 tickets, and redesigned & refined large parts of the project.
6+
7+
In order to continue driving REST framework forward, we're introducing [monthly paid plans](https://fund.django-rest-framework.org/topics/funding). These plans include various sponsorship rewards, and will ensure that the project remains sustainable and well supported.
8+
9+
We strongly believe that collaboratively funded software development yields outstanding results for a relatively low investment-per-head. If you or your company use REST framework commercially, then we would strongly urge you to participate in this latest funding drive, and help us continue to build an increasingly polished & professional product.
10+
11+
---
12+
13+
## Release notes
14+
15+
Significant new functionality in the 3.3 release includes:
16+
17+
* Filters presented as HTML controls in the browsable API.
18+
* A [forms API][forms-api], allowing serializers to be rendered as HTML forms.
19+
* Django 1.9 support.
20+
* A [`JSONField` serializer field][jsonfield], corresponding to Django 1.9's Postgres `JSONField` model field.
21+
* Browsable API support [via AJAX][ajax-form], rather than server side request overloading.
22+
23+
![Filter Controls](../img/filter-controls.png)
24+
25+
*Example of the new filter controls*
26+
27+
---
28+
29+
## Supported versions
30+
31+
This release drops support for Django 1.5 and 1.6. Django 1.7, 1.8 or 1.9 are now required.
32+
33+
This brings our supported versions into line with Django's [currently supported versions][django-supported-versions]
34+
35+
## Deprecations
36+
37+
The AJAX based support for the browsable API means that there are a number of internal cleanups in the `request` class. For the vast majority of developers this should largely remain transparent:
38+
39+
* To support form based `PUT` and `DELETE`, or to support form content types such as JSON, you should now use the [AJAX forms][ajax-forms] javascript library. This replaces the previous 'method and content type overloading' that required significant internal complexity to the request class.
40+
* The `accept` query parameter is no longer supported by the default content negotiation class. If you require it then you'll need to [use a custom content negotiation class](browser-enhancements.md#url-based-accept-headers).
41+
* The custom `HTTP_X_HTTP_METHOD_OVERRIDE` header is no longer supported by default. If you require it then you'll need to [use custom middleware](browser-enhancements.md#http-header-based-method-overriding).
42+
43+
The following pagination view attributes and settings have been moved into attributes on the pagination class since 3.1. Their usage was formerly deprecated, and has now been removed entirely, in line with the deprecation policy.
44+
45+
* `view.paginate_by` - Use `paginator.page_size` instead.
46+
* `view.page_query_param` - Use `paginator.page_query_param` instead.
47+
* `view.paginate_by_param` - Use `paginator.page_size_query_param` instead.
48+
* `view.max_paginate_by` - Use `paginator.max_page_size` instead.
49+
* `settings.PAGINATE_BY` - Use `paginator.page_size` instead.
50+
* `settings.PAGINATE_BY_PARAM` - Use `paginator.page_size_query_param` instead.
51+
* `settings.MAX_PAGINATE_BY` - Use `paginator.max_page_size` instead.
52+
53+
The `ModelSerializer` and `HyperlinkedModelSerializer` classes should now include either a `fields` or `exclude` option, although the `fields = '__all__'` shortcut may be used. Failing to include either of these two options is currently pending deprecation, and will be removed entirely in the 3.5 release. This behavior brings `ModelSerializer` more closely in line with Django's `ModelForm` behavior.
54+
55+
[forms-api]: html-and-forms.md
56+
[ajax-form]: https://github.com/tomchristie/ajax-form
57+
[jsonfield]: ../../api-guide/fields#jsonfield
58+
[django-supported-versions]: https://www.djangoproject.com/download/#supported-versions

docs/topics/release-notes.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@ You can determine your currently installed version using `pip freeze`:
4242

4343
### 3.3.0
4444

45-
**Date**: NOT YET RELEASED
46-
47-
* Removed support for Django Versions 1.5 & 1.6 ([#3421][gh3421], [#3429][gh3429])
45+
**Date**: [27th October 2015][3.3.0-milestone]
46+
47+
* HTML controls for filters. ([#3315][gh3315])
48+
* Forms API. ([#3475][gh3475])
49+
* AJAX browsable API. ([#3410][gh3410])
50+
* Added JSONField. ([#3454][gh3454])
51+
* Correctly map `to_field` when creating `ModelSerializer` relational fields. ([#3526][gh3526])
52+
* Include keyword arguments when mapping `FilePathField` to a serializer field. ([#3536][gh3536])
53+
* Map appropriate model `error_messages` on `ModelSerializer` uniqueness constraints. ([#3435][gh3435])
54+
* Include `max_length` constraint for `ModelSerializer` fields mapped from TextField. ([#3509][gh3509])
55+
* Added support for Django 1.9. ([#3450][gh3450], [#3525][gh3525])
56+
* Removed support for Django 1.5 & 1.6. ([#3421][gh3421], [#3429][gh3429])
57+
* Removed 'south' migrations. ([#3495][gh3495])
4858

4959
## 3.2.x series
5060

@@ -543,5 +553,17 @@ For older release notes, [please see the version 2.x documentation][old-release-
543553
[gh3415]: https://github.com/tomchristie/django-rest-framework/issues/3415
544554

545555
<!-- 3.3.0 -->
546-
[gh3421]: https://github.com/tomchristie/django-rest-framework/pulls/3421
547-
[gh3429]: https://github.com/tomchristie/django-rest-framework/pull/3429
556+
[gh3315]: https://github.com/tomchristie/django-rest-framework/issues/3315
557+
[gh3410]: https://github.com/tomchristie/django-rest-framework/issues/3410
558+
[gh3435]: https://github.com/tomchristie/django-rest-framework/issues/3435
559+
[gh3450]: https://github.com/tomchristie/django-rest-framework/issues/3450
560+
[gh3454]: https://github.com/tomchristie/django-rest-framework/issues/3454
561+
[gh3475]: https://github.com/tomchristie/django-rest-framework/issues/3475
562+
[gh3495]: https://github.com/tomchristie/django-rest-framework/issues/3495
563+
[gh3509]: https://github.com/tomchristie/django-rest-framework/issues/3509
564+
[gh3421]: https://github.com/tomchristie/django-rest-framework/issues/3421
565+
[gh3525]: https://github.com/tomchristie/django-rest-framework/issues/3525
566+
[gh3526]: https://github.com/tomchristie/django-rest-framework/issues/3526
567+
[gh3429]: https://github.com/tomchristie/django-rest-framework/issues/3429
568+
[gh3536]: https://github.com/tomchristie/django-rest-framework/issues/3536
569+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ pages:
5757
- '3.0 Announcement': 'topics/3.0-announcement.md'
5858
- '3.1 Announcement': 'topics/3.1-announcement.md'
5959
- '3.2 Announcement': 'topics/3.2-announcement.md'
60+
- '3.3 Announcement': 'topics/3.3-announcement.md'
6061
- 'Kickstarter Announcement': 'topics/kickstarter-announcement.md'
6162
- 'Release Notes': 'topics/release-notes.md'

rest_framework/pagination.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66
from __future__ import unicode_literals
77

8-
import warnings
98
from base64 import b64decode, b64encode
109
from collections import OrderedDict, namedtuple
1110

@@ -186,63 +185,11 @@ class PageNumberPagination(BasePagination):
186185

187186
invalid_page_message = _('Invalid page "{page_number}": {message}.')
188187

189-
def _handle_backwards_compat(self, view):
190-
"""
191-
Prior to version 3.1, pagination was handled in the view, and the
192-
attributes were set there. The attributes should now be set on
193-
the pagination class. The old style continues to work but is deprecated
194-
and will be fully removed in version 3.3.
195-
"""
196-
assert not (
197-
getattr(view, 'pagination_serializer_class', None) or
198-
getattr(api_settings, 'DEFAULT_PAGINATION_SERIALIZER_CLASS', None)
199-
), (
200-
"The pagination_serializer_class attribute and "
201-
"DEFAULT_PAGINATION_SERIALIZER_CLASS setting have been removed as "
202-
"part of the 3.1 pagination API improvement. See the pagination "
203-
"documentation for details on the new API."
204-
)
205-
206-
for (settings_key, attr_name) in (
207-
('PAGINATE_BY', 'page_size'),
208-
('PAGINATE_BY_PARAM', 'page_size_query_param'),
209-
('MAX_PAGINATE_BY', 'max_page_size')
210-
):
211-
value = getattr(api_settings, settings_key, None)
212-
if value is not None:
213-
setattr(self, attr_name, value)
214-
warnings.warn(
215-
"The `%s` settings key is deprecated. "
216-
"Use the `%s` attribute on the pagination class instead." % (
217-
settings_key, attr_name
218-
),
219-
DeprecationWarning,
220-
)
221-
222-
for (view_attr, attr_name) in (
223-
('paginate_by', 'page_size'),
224-
('page_query_param', 'page_query_param'),
225-
('paginate_by_param', 'page_size_query_param'),
226-
('max_paginate_by', 'max_page_size')
227-
):
228-
value = getattr(view, view_attr, None)
229-
if value is not None:
230-
setattr(self, attr_name, value)
231-
warnings.warn(
232-
"The `%s` view attribute is deprecated. "
233-
"Use the `%s` attribute on the pagination class instead." % (
234-
view_attr, attr_name
235-
),
236-
DeprecationWarning,
237-
)
238-
239188
def paginate_queryset(self, queryset, request, view=None):
240189
"""
241190
Paginate a queryset if required, either returning a
242191
page object, or `None` if pagination is not configured for this view.
243192
"""
244-
self._handle_backwards_compat(view)
245-
246193
page_size = self.get_page_size(request)
247194
if not page_size:
248195
return None

rest_framework/settings.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@
111111
'COMPACT_JSON': True,
112112
'COERCE_DECIMAL_TO_STRING': True,
113113
'UPLOADED_FILES_USE_URL': True,
114-
115-
# Pending deprecation:
116-
'PAGINATE_BY': None,
117-
'PAGINATE_BY_PARAM': None,
118-
'MAX_PAGINATE_BY': None
119114
}
120115

121116

tests/test_pagination.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -147,41 +147,6 @@ def test_unpaginated_list(self):
147147
assert response.data == list(range(1, 101))
148148

149149

150-
class TestDeprecatedStylePagination:
151-
"""
152-
Integration tests for deprecated style of setting pagination
153-
attributes on the view.
154-
"""
155-
156-
def setup(self):
157-
class PassThroughSerializer(serializers.BaseSerializer):
158-
def to_representation(self, item):
159-
return item
160-
161-
class ExampleView(generics.ListAPIView):
162-
serializer_class = PassThroughSerializer
163-
queryset = range(1, 101)
164-
pagination_class = pagination.PageNumberPagination
165-
paginate_by = 20
166-
page_query_param = 'page_number'
167-
168-
self.view = ExampleView.as_view()
169-
170-
def test_paginate_by_attribute_on_view(self):
171-
request = factory.get('/?page_number=2')
172-
response = self.view(request)
173-
assert response.status_code == status.HTTP_200_OK
174-
assert response.data == {
175-
'results': [
176-
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
177-
31, 32, 33, 34, 35, 36, 37, 38, 39, 40
178-
],
179-
'previous': 'http://testserver/',
180-
'next': 'http://testserver/?page_number=3',
181-
'count': 100
182-
}
183-
184-
185150
class TestPageNumberPagination:
186151
"""
187152
Unit tests for `pagination.PageNumberPagination`.

0 commit comments

Comments
 (0)