mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
serializers,docs: remove some DRF 2.x references
The last release of DRF 2.x was 5 years ago, it seems fine to remove these references now.
This commit is contained in:
parent
03a06d9083
commit
4cdd57e266
|
@ -597,8 +597,6 @@ The `.to_representation()` method is called to convert the initial datatype into
|
||||||
|
|
||||||
The `to_internal_value()` method is called to restore a primitive datatype into its internal python representation. This method should raise a `serializers.ValidationError` if the data is invalid.
|
The `to_internal_value()` method is called to restore a primitive datatype into its internal python representation. This method should raise a `serializers.ValidationError` if the data is invalid.
|
||||||
|
|
||||||
Note that the `WritableField` class that was present in version 2.x no longer exists. You should subclass `Field` and override `to_internal_value()` if the field supports data input.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### A Basic Custom Field
|
### A Basic Custom Field
|
||||||
|
|
|
@ -175,8 +175,6 @@ You can also use these hooks to provide additional validation, by raising a `Val
|
||||||
raise ValidationError('You have already signed up')
|
raise ValidationError('You have already signed up')
|
||||||
serializer.save(user=self.request.user)
|
serializer.save(user=self.request.user)
|
||||||
|
|
||||||
**Note**: These methods replace the old-style version 2.x `pre_save`, `post_save`, `pre_delete` and `post_delete` methods, which are no longer available.
|
|
||||||
|
|
||||||
**Other methods**:
|
**Other methods**:
|
||||||
|
|
||||||
You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using `GenericAPIView`.
|
You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using `GenericAPIView`.
|
||||||
|
|
|
@ -166,13 +166,6 @@ class BaseSerializer(Field):
|
||||||
raise NotImplementedError('`create()` must be implemented.')
|
raise NotImplementedError('`create()` must be implemented.')
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
assert not hasattr(self, 'save_object'), (
|
|
||||||
'Serializer `%s.%s` has old-style version 2 `.save_object()` '
|
|
||||||
'that is no longer compatible with REST framework 3. '
|
|
||||||
'Use the new-style `.create()` and `.update()` methods instead.' %
|
|
||||||
(self.__class__.__module__, self.__class__.__name__)
|
|
||||||
)
|
|
||||||
|
|
||||||
assert hasattr(self, '_errors'), (
|
assert hasattr(self, '_errors'), (
|
||||||
'You must call `.is_valid()` before calling `.save()`.'
|
'You must call `.is_valid()` before calling `.save()`.'
|
||||||
)
|
)
|
||||||
|
@ -216,13 +209,6 @@ class BaseSerializer(Field):
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
def is_valid(self, raise_exception=False):
|
def is_valid(self, raise_exception=False):
|
||||||
assert not hasattr(self, 'restore_object'), (
|
|
||||||
'Serializer `%s.%s` has old-style version 2 `.restore_object()` '
|
|
||||||
'that is no longer compatible with REST framework 3. '
|
|
||||||
'Use the new-style `.create()` and `.update()` methods instead.' %
|
|
||||||
(self.__class__.__module__, self.__class__.__name__)
|
|
||||||
)
|
|
||||||
|
|
||||||
assert hasattr(self, 'initial_data'), (
|
assert hasattr(self, 'initial_data'), (
|
||||||
'Cannot call `.is_valid()` as no `data=` keyword argument was '
|
'Cannot call `.is_valid()` as no `data=` keyword argument was '
|
||||||
'passed when instantiating the serializer instance.'
|
'passed when instantiating the serializer instance.'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user