mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
Release notes
This commit is contained in:
parent
63d02dbea8
commit
0c65e028b6
|
@ -146,7 +146,7 @@ The decorators can additionally take extra arguments that will be set for the ro
|
||||||
def set_password(self, request, pk=None):
|
def set_password(self, request, pk=None):
|
||||||
...
|
...
|
||||||
|
|
||||||
The `@action` decorator will route `POST` requests by default, but may also accept other HTTP methods, by using the `methods` argument. For example:
|
Theses decorators will route `GET` requests by default, but may also accept other HTTP methods, by using the `methods` argument. For example:
|
||||||
|
|
||||||
@detail_route(methods=['post', 'delete'])
|
@detail_route(methods=['post', 'delete'])
|
||||||
def unset_password(self, request, pk=None):
|
def unset_password(self, request, pk=None):
|
||||||
|
|
|
@ -1,4 +1,111 @@
|
||||||
* List/detail routes.
|
# REST framework 2.4 announcement
|
||||||
* 1.3 Support dropped, install six for <=1.4.?.
|
|
||||||
|
The 2.4 release is largely an intermediate step, tying up some outstanding issues prior to the 3.x series.
|
||||||
|
|
||||||
|
## Version requirements
|
||||||
|
|
||||||
|
Support for Django 1.3 has been dropped.
|
||||||
|
The lowest supported version of Django is now 1.4.2.
|
||||||
|
|
||||||
|
The current plan is for REST framework to remain in lockstep with [Django's long-term support policy][lts-releases].
|
||||||
|
|
||||||
|
## Django 1.7 support
|
||||||
|
|
||||||
|
The optional authtoken application now includes support for *both* Django 1.7 schema migrations, *and* for old-style `south` migrations.
|
||||||
|
|
||||||
|
**If you are using authtoken, and you want to continue using `south`, you must upgrade your `south` package to version 1.0.**
|
||||||
|
|
||||||
|
## Updated test runner
|
||||||
|
|
||||||
|
We now have a new test runner for developing against the project,, that uses the excellent [py.test](http://pytest.org) library.
|
||||||
|
|
||||||
|
To use it make sure you have first installed the test requirements.
|
||||||
|
|
||||||
|
pip install -r requirements-test.txt
|
||||||
|
|
||||||
|
Then run the `runtests.py` script.
|
||||||
|
|
||||||
|
./runtests.py
|
||||||
|
|
||||||
|
The new test runner also includes [flake8](https://flake8.readthedocs.org) code linting, which should help keep our coding style consistent.
|
||||||
|
|
||||||
|
#### Test runner flags
|
||||||
|
|
||||||
|
Run using a more concise output style.
|
||||||
|
|
||||||
|
./runtests -q
|
||||||
|
|
||||||
|
Run the tests using a more concise output style, no coverage, no flake8.
|
||||||
|
|
||||||
|
./runtests --fast
|
||||||
|
|
||||||
|
Don't run the flake8 code linting.
|
||||||
|
|
||||||
|
./runtests --nolint
|
||||||
|
|
||||||
|
Only run the flake8 code linting, don't run the tests.
|
||||||
|
|
||||||
|
./runtests --lintonly
|
||||||
|
|
||||||
|
Run the tests for a given test case.
|
||||||
|
|
||||||
|
./runtests MyTestCase
|
||||||
|
|
||||||
|
Run the tests for a given test method.
|
||||||
|
|
||||||
|
./runtests MyTestCase.test_this_method
|
||||||
|
|
||||||
|
Shorter form to run the tests for a given test method.
|
||||||
|
|
||||||
|
./runtests test_this_method
|
||||||
|
|
||||||
|
Note: The test case and test method matching is fuzzy and will sometimes run other tests that contain a partial string match to the given command line input.
|
||||||
|
|
||||||
|
## Improved viewset routing
|
||||||
|
|
||||||
|
The `@action` and `@link` decorators were inflexible in that they only allowed additional routes to be added against instance style URLs, not against list style URLs.
|
||||||
|
|
||||||
|
The `@action` and `@link` decorators have now been moved to pending deprecation, and the `@list_route` and `@detail_route` decroators have been introduced.
|
||||||
|
|
||||||
|
Here's an example of using the new decorators. Firstly we have a detail-type route named "set_password" that acts on a single instance, and takes a `pk` argument in the URL. Secondly we have a list-type route named "recent_users" that acts on a queryset, and does not take any arguments in the URL.
|
||||||
|
|
||||||
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
A viewset that provides the standard actions
|
||||||
|
"""
|
||||||
|
queryset = User.objects.all()
|
||||||
|
serializer_class = UserSerializer
|
||||||
|
|
||||||
|
@detail_route(methods=['post'])
|
||||||
|
def set_password(self, request, pk=None):
|
||||||
|
user = self.get_object()
|
||||||
|
serializer = PasswordSerializer(data=request.DATA)
|
||||||
|
if serializer.is_valid():
|
||||||
|
user.set_password(serializer.data['password'])
|
||||||
|
user.save()
|
||||||
|
return Response({'status': 'password set'})
|
||||||
|
else:
|
||||||
|
return Response(serializer.errors,
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
@list_route()
|
||||||
|
def recent_users(self, request):
|
||||||
|
recent_users = User.objects.all().order('-last_login')
|
||||||
|
page = self.paginate_queryset(recent_users)
|
||||||
|
serializer = self.get_pagination_serializer(page)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
For more details, see the [viewsets](../api-guide/viewsets.md) documentation.
|
||||||
|
|
||||||
|
## Other features
|
||||||
|
|
||||||
|
## Deprecations
|
||||||
|
|
||||||
|
## Labels and milestones
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
* `allow_none` for char fields
|
* `allow_none` for char fields
|
||||||
* `trailing_slash = True` --> `[^/]`, `trailing_slash = False` --> `[^/.]`, becomes simply `[^/]` and `lookup_value_regex` is added.
|
* `trailing_slash = True` --> `[^/]`, `trailing_slash = False` --> `[^/.]`, becomes simply `[^/]` and `lookup_value_regex` is added.
|
||||||
|
|
||||||
|
[lts-releases]: https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-support-lts-releases
|
|
@ -38,26 +38,35 @@ You can determine your currently installed version using `pip freeze`:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 2.4.x series
|
||||||
|
|
||||||
### 2.4.0
|
### 2.4.0
|
||||||
|
|
||||||
* Added compatibility with Django 1.7's native migrations.
|
**Django version requirements**: The lowest supported version of Django is now 1.4.2.
|
||||||
|
|
||||||
**IMPORTANT**: In order to continue to use South with Django <1.7 you **must** upgrade to
|
**South version requirements**: This note applies to any users using the optional `authtoken` application, which includes an associated database migration. You must now *either* upgrade your `south` package to version 1.0, *or* instead use the built-in migration support available with Django 1.7.
|
||||||
South v1.0.
|
|
||||||
|
|
||||||
* Use py.test
|
* Added compatibility with Django 1.7's database migration support.
|
||||||
|
* New test runner, using `py.test`.
|
||||||
* `@detail_route` and `@list_route` decorators replace `@action` and `@link`.
|
* `@detail_route` and `@list_route` decorators replace `@action` and `@link`.
|
||||||
* `six` no longer bundled. For Django <= 1.4.1, install `six` package.
|
|
||||||
* Support customizable view name and description functions, using the `VIEW_NAME_FUNCTION` and `VIEW_DESCRIPTION_FUNCTION` settings.
|
* Support customizable view name and description functions, using the `VIEW_NAME_FUNCTION` and `VIEW_DESCRIPTION_FUNCTION` settings.
|
||||||
* Added `NUM_PROXIES` setting for smarter client IP identification.
|
* Added `NUM_PROXIES` setting for smarter client IP identification.
|
||||||
* Added `MAX_PAGINATE_BY` setting and `max_paginate_by` generic view attribute.
|
* Added `MAX_PAGINATE_BY` setting and `max_paginate_by` generic view attribute.
|
||||||
* Added `cache` attribute to throttles to allow overriding of default cache.
|
* Added `cache` attribute to throttles to allow overriding of default cache.
|
||||||
|
* Added `lookup_value_regex` attribute to routers, to allow the URL argument matching to be constrainted by the user.
|
||||||
|
* Added `allow_none` option to `CharField`.
|
||||||
|
* Support Django's standard `status_code` class attribute on responses.
|
||||||
|
* More intuitive behavior on the test client, as `client.logout()` now also removes any credentials that have been set.
|
||||||
* Bugfix: `?page_size=0` query parameter now falls back to default page size for view, instead of always turning pagination off.
|
* Bugfix: `?page_size=0` query parameter now falls back to default page size for view, instead of always turning pagination off.
|
||||||
|
* Bugfix: Always uppercase `X-Http-Method-Override` methods.
|
||||||
|
* Bugfix: Copy `filter_backends` list before returning it, in order to prevent view code from mutating the class attribute itself.
|
||||||
|
* Bugfix: Set the `.action` attribute on viewsets when introspected by `OPTIONS` for testing permissions on the view.
|
||||||
|
* Bugfix: Ensure `ValueError` raised during deserialization results in a error list rather than a single error. This is now consistent with other validation errors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 2.3.x series
|
## 2.3.x series
|
||||||
|
|
||||||
|
|
||||||
### 2.3.14
|
### 2.3.14
|
||||||
|
|
||||||
**Date**: 12th June 2014
|
**Date**: 12th June 2014
|
||||||
|
|
Loading…
Reference in New Issue
Block a user