mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Add .model deprecation to release notes
This commit is contained in:
parent
4d8c63abc9
commit
8b2052172c
|
@ -74,10 +74,6 @@ The following attributes control the basic view behavior.
|
|||
* `lookup_field` - The model field that should be used to for performing object lookup of individual model instances. Defaults to `'pk'`. Note that when using hyperlinked APIs you'll need to ensure that *both* the API views *and* the serializer classes set the lookup fields if you need to use a custom value.
|
||||
* `lookup_url_kwarg` - The URL keyword argument that should be used for object lookup. The URL conf should include a keyword argument corresponding to this value. If unset this defaults to using the same value as `lookup_field`.
|
||||
|
||||
**Shortcuts**:
|
||||
|
||||
* `model` - This shortcut may be used instead of setting either (or both) of the `queryset`/`serializer_class` attributes, although using the explicit style is generally preferred. If used instead of `serializer_class`, then `DEFAULT_MODEL_SERIALIZER_CLASS` setting will determine the base serializer class. Note that `model` is only ever used for generating a default queryset or serializer class - the `queryset` and `serializer_class` attributes are always preferred if provided.
|
||||
|
||||
**Pagination**:
|
||||
|
||||
The following attributes are used to control pagination when used with list views.
|
||||
|
@ -91,6 +87,10 @@ The following attributes are used to control pagination when used with list view
|
|||
|
||||
* `filter_backends` - A list of filter backend classes that should be used for filtering the queryset. Defaults to the same value as the `DEFAULT_FILTER_BACKENDS` setting.
|
||||
|
||||
**Deprecated attributes**:
|
||||
|
||||
* `model` - This shortcut may be used instead of setting either (or both) of the `queryset`/`serializer_class` attributes. The explicit style is preferred over the `.model` shortcut, and usage of this attribute is now deprecated.
|
||||
|
||||
### Methods
|
||||
|
||||
**Base methods**:
|
||||
|
|
|
@ -100,12 +100,6 @@ Default: `'rest_framework.negotiation.DefaultContentNegotiation'`
|
|||
|
||||
*The following settings control the behavior of the generic class based views.*
|
||||
|
||||
#### DEFAULT_MODEL_SERIALIZER_CLASS
|
||||
|
||||
A class that determines the default type of model serializer that should be used by a generic view if `model` is specified, but `serializer_class` is not provided.
|
||||
|
||||
Default: `'rest_framework.serializers.ModelSerializer'`
|
||||
|
||||
#### DEFAULT_PAGINATION_SERIALIZER_CLASS
|
||||
|
||||
A class the determines the default serialization style for paginated responses.
|
||||
|
|
|
@ -139,7 +139,7 @@ Here's our project's root `urls.py` module:
|
|||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
|
||||
You can now open the API in your browser at [http://127.0.0.1:8000/](http://127.0.0.1:8000/), and view your new 'users' API. If you use the Login control in the top right corner you'll also be able to add, create and delete users from the system.
|
||||
You can now open the API in your browser at [http://127.0.0.1:8000/](http://127.0.0.1:8000/), and view your new 'users' API. If you use the login control in the top right corner you'll also be able to add, create and delete users from the system.
|
||||
|
||||
## Quickstart
|
||||
|
||||
|
|
|
@ -15,6 +15,16 @@ The optional authtoken application now includes support for *both* Django 1.7 sc
|
|||
|
||||
**If you are using authtoken, and you want to continue using `south`, you must upgrade your `south` package to version 1.0.**
|
||||
|
||||
## Deprecation of `.model` view attribute
|
||||
|
||||
The `.model` attribute on view classes is an optional shortcut for either or both of `.serializer_class` and `.queryset`. It's usage results in more implicit, less obvious behavior.
|
||||
|
||||
The documentation has previously stated that usage of the more explict style is prefered, and we're now taking that one step further and deprecating the usage of the `.model` shortcut.
|
||||
|
||||
Doing so will mean that there are cases of API code where you'll now need to include a serializer class where you previously were just using the `.model` shortcut. However we firmly believe that it is the right trade-off to make. Removing the shortcut takes away an unneccessary layer of abstraction, and makes your codebase more explict without any significant extra complexity.
|
||||
|
||||
The `DEFAULT_MODEL_SERIALIZER_CLASS` API setting is now also deprecated.
|
||||
|
||||
## 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.
|
||||
|
|
|
@ -48,6 +48,7 @@ You can determine your currently installed version using `pip freeze`:
|
|||
|
||||
* Added compatibility with Django 1.7's database migration support.
|
||||
* New test runner, using `py.test`.
|
||||
* Deprecated `.model` view attribute in favor of explict `.queryset` and `.serializer_class` attributes. The `DEFAULT_MODEL_SERIALIZER_CLASS` setting is also deprecated.
|
||||
* `@detail_route` and `@list_route` decorators replace `@action` and `@link`.
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user